So I have a .htaccess rewrite rule to remove the ".php" extension. It works. So now when a user goes to /page it shows /page.php. But is there any way to make it so that when a user goes to /page.php it'll show /page in the address bar?
1 Answer
try this:
RewriteCond %{ENV:REDIRECT_STATUS} 200 RewriteRule ^ - [L] RewriteRule (.+)\.php$ $1 [R,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ $1.php [L] 3 Comments
David Maksimov
Would this affect the POST method in any way? I'm having problems with it.
ThinkingMonkey
It definitely shouldn't. What is the problem you are having?
David Maksimov
The thing is that all the links on my pages are already set with a '.php' extension. So in my form, it action="sendcontactus.php". So I'm guessing what happens is that when this form submits, it performs the url rewrite to a link without the ".php" extension and the POST values get lost in the process.