0

my first page in my website called index.html when I put in the address bar : http://websit/index.html it works

but

now my boss asked me that he wants the name just http://websit/index

how can I do that?

  • maybe duplicates: http://stackoverflow.com/questions/10245032/url-rewrite-remove-html – mdn Jan 25 '13 at 16:12

2 Answers2

0

Standard web server behavior is to just load the "index.html" file as the root file of a path call. Meaning this:

http://websit/

Is the same as this:

http://websit/index.html

Doing something like this (below) will only cause more problems since it would seem that index is a path instead of a file:

http://websit/index

So any if you want to clean things up just make any reference to http://websit/index.html just http://websit/

Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
0

If you are using Apache, then, you need to check if Mod Rewrite is enabled, and then, read articles about .htaccess and mod rewrite.

The solution: Create a file with this name exactly .htaccess on root directory (where the index.html) is there. Then, copy this code (paste it inside the .htaccess file) and test it again using website/index without .html

#comments
RewriteEngine On

#base directory for this file, if its root, then its one /, if its test then its /test
RewriteBase /

#if the URL for the resource that requested is not exist as file
RewriteCond %{SCRIPT_FILENAME} !-f

#if the URL for the resource not exist as directory
RewriteCond %{SCRIPT_FILENAME} !-d

#then it anything types after the website/() redirect it to ().html
RewriteRule ^(.*)$ $1.html [NC,L]

#the ^ and $ used for matching whole string (from beginning to end)
#the () used for grouping matching strings
#the . used for matching any character
#the $1 represents the match group, for our example we used one () then its $1

[1] http://httpd.apache.org/docs/current/howto/htaccess.html