0

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]
0

1 Answer 1

2

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

2 Comments

I got this working now. Had to put a .htaccess in every subdirectory. Not the most ideal solution, but working for now.
Good Mr. @dexter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.