felito Posted April 5, 2011 Share Posted April 5, 2011 hi i tried this code, but i get an error because the last line RewriteRule \.php$ - [R=404,L] RewriteEngine on # allow example.com/foo RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !\.php$ RewriteRule ^(.+)$ /$1.php?myvar=0 [L] # but don't allow example.com/foo.php RewriteCond %{QUERY_STRING} !^myvar=0$ RewriteRule \.php$ - [R=404,L] any idea? i want to redirect the access to all files with termination with .php thanks Quote Link to comment Share on other sites More sharing options...
Maq Posted April 5, 2011 Share Posted April 5, 2011 For future reference we have a mod_rewrite section, I already moved your thread there. Quote Link to comment Share on other sites More sharing options...
felito Posted April 5, 2011 Author Share Posted April 5, 2011 log [Tue Apr 05 16:16:26 2011] [notice] Child 3972: Child process is running [Tue Apr 05 16:16:26 2011] [notice] Child 3972: Acquired the start mutex. [Tue Apr 05 16:16:26 2011] [notice] Child 3972: Starting 250 worker threads. [Tue Apr 05 16:16:26 2011] [alert] [client 127.0.0.1] C:/Users/fel/VertrigoServ/www/.htaccess: RewriteRule: invalid HTTP response code for flag 'R' Quote Link to comment Share on other sites More sharing options...
dcro2 Posted April 9, 2011 Share Posted April 9, 2011 Apparently you can't use R=404 on apache < 2.2. So you'll have to redirect instead to a file you know will return a 404 error. Ie. # but don't allow example.com/foo.php RewriteCond %{QUERY_STRING} !^myvar=0$ RewriteRule \.php$ /nonexistantfile [L] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.