How do I remove .html extensions from my web pages?

Asked by:
HubFans / n/a Points
Time:
2015-09-13 12:50 am EST
Category:
File Management
Hits:
784
I typed the following code into my htaccess file:

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

My file extensions are still showing up on my site. I tried renaming all my files without the .html and changing the links in my actual code, all to no avail. Has anyone else been able to figure this out?

To ask this user for more information, please first login.

To submit an answer, please login.

ANSWERS

0

ScottM
Staff
16,266 Points
2015-09-14 3:54 pm EST
Hello,

Thank you for your question on removing html file extensions. The code we have given those who want to remove extensions is below, there is one for php and one for html.

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

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

Give that a try and you should be fine. Keep in mind if someone types in the .html extension it still may show up. This is largely to allow the use (links, URLs,etc) to be used with or without the extension.

Kindest Regards,
Scott M

To submit a comment on this answer, please first login.

0

W3Specs
2022-03-09 12:36 pm EST
How are so many people so stupid? I mean, you can't remove the extension, since if you do that, the browser won't know how should it render the specified file, will it be .txt, .html, .htm, .css, .js, etc...

And no, there isn't a script which works. If anyone was wondering.

To submit a comment on this answer, please first login.

Want to share this Question?

Related Articles

It looks like there are no related articles.
Would you like to ask a question about this page? If so, click the button below!
Need More Help?

Help Center Search

Current Customers

Email: support@WebHostingHub.com Ticket: Submit a Support Ticket
Call: 877-595-4HUB (4482)
757-416-6627 (Intl.)
Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.
}