How to remove file extensions from URLs

Asked by:
genegun / 8 Points
Time:
2012-02-12 1:25 pm EST
Category:
Htaccess
Hits:
2,818
Hi,

I tried to get the .htaccess file to redirect http://www.example/page.html to http://www.example/page with the following code:

RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^(.*)\.html$ $1 [R=301,L]

now the redirect does remove the ".html" BUT it yields to an url like: http://www.example/home/myaccount/public_html/page

How can I set this redirect so it does not add the "/home/myaccount/public_html/" bit?

Thank you

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

To submit an answer, please login.

Best answer chosen by Web Hosting Hub staff

0

ChristiNi
Staff
13,688 Points
2012-02-13 6:32 pm EST
Hello genegun,

Thank you for your question about removing the file extension from your site's URLs. You can use the following code in your .htaccess file to use URLs like http://www.example/page or http://www.example/page/ instead of http://www.example/page.html:

Options +MultiViews

Please make sure you remove the previous code from the .htaccess file.

If you have any additional questions or need further assistance, please do not hesitate to contact us.

Regards,

Christi N.

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.
}