Reputation: 165
I have a .htaccess
file to hide .php
extensions. When I enter the url (localhost, apache) it does work (in the browser I type: localhost/project_test) and then it gives me localhost/project_test/login (which was login.php), but when I want to login (and redirect to another page called portal.php in the same directory) the redirect to portal.php doesn't work
My .htaccess
code:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://localhost/project_test/production/$1 [R=301,L]
RewriteRule ^([^/.]+)$ $1.php [L]
Upvotes: 0
Views: 97
Reputation: 1056
To remove the .php extension from a PHP file for example yoursite.com/wallpaper.php to yoursite.com/wallpaper you have to add the following code inside the .htaccess file:
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
Upvotes: 2