-2

I'm creating a website for my personal needs. I have different pages like index.html, about.html, contact.html etc... The default way of showing them is mysite.com/index.html or mysite.com/contact.html

But is there any way to hide the extension part .html and just to show the url main texts like mysite.com/about/ or mysite.com/contact/ ??

Please advice me.

Roberto Maldonado
  • 1,585
  • 14
  • 27
user1012181
  • 8,648
  • 10
  • 64
  • 106
  • Well `mysite.com/about/` is generally the same as `mysite.com/about/index.html` (depending on server settings). For a more dynamic approach you would use URL Rewriting http://en.wikipedia.org/wiki/Rewrite_engine – Alex K. Feb 05 '14 at 12:57
  • @deceze, thanks for noticing me this thread too! – user1012181 Feb 05 '14 at 13:05

2 Answers2

4

You have to use a URL rewrite engine, edit (or create) the .htaccess like that:

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

For more details: Remove .html from URLs with a redirect

Community
  • 1
  • 1
Zealot
  • 687
  • 4
  • 17
  • Adding to this answer, your web server has to support url rewriting. For Apache (one of the most used) you have to install a module called mod_rewrite. For other web servers, look at the docs if they support it. – Roberto Maldonado Feb 05 '14 at 13:02
-1

It's possible to show your page with mysite.com/about/

  1. You need to replace all file name to index.html
  2. Eg : about.html to index.html
  3. Add index.html to their respective pages, like

Before:

www/
|
|-about/about.html
|
|-contact/contact.html
|
|-etc/etc.html

After :

www/
|
|-about/index.html
|
|-contact/index.html
|
|-etc/index.html

Now when you hit the URL www.yourSite.com/about that page will be shown. (without about.html part)

yashhy
  • 2,856
  • 5
  • 31
  • 57