APIUM
APIUM

Reputation: 57

How to stop .html showing up in the url?

This is probably a really simple fix, but how do I set it so when you go to my site (www.skidsfordays.com) it jsut comes up as that and not www.skidsfordays.com/index.html and then every page on the site has .html after it. How can I fix this? Thanks.

Upvotes: 3

Views: 5425

Answers (2)

codeee
codeee

Reputation: 397

To hide index.html please Add below code in below code in your .htaccess file here we rewrite the index.html url to your site domain:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.yoursite\.com [OR]
RewriteCond %{REQUEST_URI} /index\.html$
RewriteRule (.*?)(index\.html)?$ http://yoursite.com$1 [NE,R=301,L]

To hide .html Extension please try below code

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

Upvotes: 0

xate
xate

Reputation: 6379

Create a .htaccess in your web root directory and add the following line into it:

Options +Multiviews

-> Done.

This means, that the server does not require the file extension (for example: .html, .php ) to load the requested file.

Upvotes: 6

Related Questions