1

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 1

3

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] 
Sign up to request clarification or add additional context in comments.

3 Comments

Would this affect the POST method in any way? I'm having problems with it.
It definitely shouldn't. What is the problem you are having?
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.