Reputation: 4949
I want to redirect only php files and files with no file extension like these:
http://www.test.com/test.php
http://www.test.com/TEST
I have this htaccess script, which redirects php files to target.php:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^[^\.]+\.php$ /target.php [L,NC]
Now I need to add files with no extension to this redirect.
Thanks for help!
Upvotes: 1
Views: 819
Reputation: 165138
These rules should do the job.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^[^\.]+\.php$ /target.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^[^\.]*[^/\.]$ /target.php [L,NC]
The redirect will work for http://www.test.com/TEST
as long as you do not have folder or file named TEST
in your site.
Upvotes: 1