Welcome to WebmasterWorld Guest from 54.145.208.64

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

how to remove index.html from the URL

if index.html found remove it from url

   
8:17 am on Apr 30, 2007 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Hi

I want to redirect URLs like

www.domain.com/tagword/main/index.html

to

www.domain.com/tagword/main/

and

www.domain.com/tagword/main/sub/index.html

to

www.domain.com/tagword/main/sub/

after the redirection there are two rules which will open the index.html page automatically, All I want is to hide index.html from the URLs.

I am not sure what kinda rule should I use for this?

P.S tagword is a hardcoded entity in the URL which appears always so only main and sub are the variables.

8:45 am on Apr 30, 2007 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



just to add more, I am trying the following but it does not make any difference to the URL and index.html remains in the URL

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_URI} ^/tagword/.*$
RewriteRule ^tagword/([^.]+)/index\.html$ tagword/$1/ [L]

2:57 pm on Apr 30, 2007 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



You'll need to do two things:

First, remove "index.html" from the links on all of your pages -- A multi-file editor (many free/shareware programs available) is handy for this purpose. It is the links on your pages which determine the URL, while internal rewrites (including DirectroyIndex) associate a "Web" URL with a server filepath.

Then redirect only client requests for "/index.html" to "/". This restriction is necessary to prevent a loop, since DirectoryIndex will rewrite "/" back to "/index.html" and if you overlook it, you'll create an 'infinite' redirect/rewrite loop.


RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /tagword/([^/]+/)*index\.html
RewriteRule ^tagword/(([^/]+/)*)index\.html$ http://www.example.com/tagword/$1 [R=301,L]

Both steps are required to "change" a URL and get the search engines to drop the old one.

THE_REQUEST is the HTTP request header as received from the client (browser or 'bot), and might look like this:

GET /tagword/main/sub/index.html HTTP/1.1

Jim

3:27 pm on Apr 30, 2007 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



I usually redirect (index¦default¦home)\.(html?¦php¦asp¦cfm¦jsp) in all folders and in root to a URL that does not include the index file filename.

This stops people guessing what underlying technology actually runs the website, and allows a change of technology at any time without exposing new URLs for indexing.

This redirect also forces the correct domain (i.e. www.domain.com) in the redirect.

This redirect therefore goes before the main non-www to www redirect code, so that index URLs are not redirected twice.