Reputation: 369
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?
Upvotes: 1
Views: 1162
Reputation: 12727
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]
Upvotes: 3