0
votes

i am trying to remove the ending extensions of my website when navigating to another page on my website but the extensions are still there after modifying my .htaccess file.

Example:

Current look: website.com/index.html

How i want it: Website.com/index

Inside File:

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

1
What do you have in your htaccess file?ralph.m
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.html -f RewriteRule ^(.*)$ $1.htmluser2557358

1 Answers

1
votes

Below I have pasted the url rewriting code necessary to chop off extensions manually, which should be in .htaccess file in the directory of your website that you would like to rewrite the extensions for.

RewriteEngine On
RewriteRule   horses.htm   Xu8JuefAtua.htm

This simply displays the horses.htm page as Xu8JuefAtua.htm in the address bar.

To rewrite a url to not need the file extension and be case insensitive, then this is the code you are looking for:

RewriteEngine On
RewriteRule   ^horses/?$   Xu8JuefAtua.html  [NC]

The regular expression ^ means the beginning of the URL path, the ? means that the preceding character, in this case a slash in not necessary. The $ matches the end of the url.

Smashing Magazine gives a great writeup on the .htaccess file and how to use Regular expressions to do all kinds of things, check out their post.