-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,555
  • 14
  • 26
user1012181
  • 8,290
  • 9
  • 60
  • 102
  • 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
  • 657
  • 4
  • 16
-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,741
  • 5
  • 28
  • 54