homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

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)


I want to redirect URLs like








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)

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)

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



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

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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved