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

2
  • 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 en.wikipedia.org/wiki/Rewrite_engine Commented Feb 5, 2014 at 12:57
  • @deceze, thanks for noticing me this thread too! Commented Feb 5, 2014 at 13:05

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

1 Comment

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

6 Comments

-1. Sorry, that's a really poor suggestion.
he haven't mentioned any server side URL rewriting for this, so basic OP is this I believe!
It's irrelevant if the OP mentioned it or not. This is a bad solution.
OP didn't mentioned it because maybe he didn't know. Your intentions were good, but far from optimal
What is this OP anyway?? OutPut?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.