Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

mod_rewrite only one index.html page

and not all index.html pages



6:23 am on Oct 28, 2004 (gmt 0)

10+ Year Member

I try to get the 404 error messages out of my log.

Some bots try to access foo.com/index.html but there is now such file. There is only one foo.com/index.php which is the startpage.

But I have hundrets of index.html files in subdirs like foo.com/abc/index.html

I don't know how to handle it graceful via htaccess :(

This does not work:
RedirectMatch [foo.com...] [foo.com...]

Any Ideas?


12:54 pm on Oct 28, 2004 (gmt 0)

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

Have you tried:

RedirectMatch 301 ^/index.html$ http://www.foo.com/index.php

You should not include the domain part in the pattern, and anchoring the URL-path pattern makes it more specific.

Specifying a 301-Moved Permanently redirect status will tell search engines to update the URL in their index. This will prevent problems with your search engine listings.

The RedirectMatch directive is not processed by mod_rewrite, but rather by mod_alias.



7:45 am on Oct 29, 2004 (gmt 0)

10+ Year Member

Thanks jdMorgan for the head up...


6:18 pm on Oct 30, 2004 (gmt 0)

10+ Year Member

Short question again:

Is it somehow possible to have the "DirectoryIndex" only for the frontpage?

www.foo.com/index.php <- DirectoryIndex

www.goo.com/2/34/567/index.html <- DirectoryIndex


There are around 500 subdirs and a htacess for all of them is a pain in the .. brain ;)


1:33 am on Oct 31, 2004 (gmt 0)

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

DirectoryIndex, if set in your root directory, would have to be overridden in each subdirectory below your root directory (subdirectories below those subdirectories would not need an .htaccess file, they would inherit the setting from their parent directory.)

In your case case, I'd recommend you just set DirectoryIndex to index.html, and then use mod_rewrite to internally rewrite index.html to index.php in the root directory only. That would avoid having to put an .htaccess file in each subdirectory of root.

This problem is much easier to solve if you have access to httpd.conf... :(



Featured Threads

Hot Threads This Week

Hot Threads This Month