How to remove the .php extension from url


As soon as is add the code in .htaccess regarding php extension removal my site doesn’t get redirected to the particular directory as i have created a folder inside that their are 2 different folders one is for students and other one is for faculty so as soon as i type /student.php it doesn’t get redirected to /student even after adding it to .htaccess.

Following is the code which i have added to .htaccess:-

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php

This is the link of the site:

Remove the code you have used, an put this instead.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
1 Like

Still not working brother



I think it’s because of the slash in the end in the name of these directories

and .htaccess then ignores because I think it sees TWO // instead of one

so it leave the extension intact.

but at the moment I do not have time to devote in more detail and to be fully convinced that this is the reason. -sorry


How about this?

Options +MultiViews
RewriteEngine on
RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [NC,L]

Didn’t work

I tried doing this as well but its not responding link gets broken in between

Issues with your file structure ig.

1 Like


How to Name Files/folders

Do Not Use Special Characters

For best results, you should only use the letters a-z, A-Z, the numbers 0-9, hyphens (-), underscores (_) and periods (.). Any other character could get you in trouble, causing the file not to load or the page to load incorrectly.
it is best to use lowercase letters, also Do Not Use Any Spaces


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.