Question

I have a file and folder with the same name with dropping file extensions

I know that I can fix my .htaccess I just dont have any knowledge on .htaccess:

DirectorySlash Off
Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
RewriteRule ^ %1 [R,L,NC]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [L]

ErrorDocument 404 /404.html
ErrorDocument 403 /403.html
Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @Filice,

I’m not sure I understand the question exactly. What I understand is that you wish your website to load without using the file’s extensions. For example, if you have a domain.com and someone loads the contact.php form to look like domain.com/contact, is that correct?

Removing Extensions

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:

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

If you want to remove the .html extension from a html file for example yoursite.com/wallpaper.html to yoursite.com/wallpaper you simply have to change the last line from the code above, to match the filename:

RewriteRule ^([^\.]+)$ $1.html [NC,L]

Regards, KFSys