rewrite is directing people to the wrong index page?

Hello! I have recently installed the mod_rewrite module, and configured it so when someone enters a subdomain ( they are transparently directed to It works okay, but when arriving at the destination, it claims it cannot find index.html there.

There is an index.php in there, shouldn't that be picked up too? I even went into /test/ and made an .htaccess file that says DirectoryIndex index.php. When i access the page via, the index loads fine. When I go through, it says 'index.html is not found, bleh bleh'.

I need to know where the discrepancy here is being introduced, so I can fix it! Thanks!

6 Replies

Can you post the actual rewrite rules you are using?

Here is the full text of my main .htaccess file

DirectoryIndex index.html index.php index.htm

RewriteEngine On

RewriteCond %{HTTP_HOST} !^$

RewriteCond %{HTTP_HOST} !^(www.)?$ [NC]

RewriteCond %{HTTPHOST}<->%{REQUESTURI} ^(www.)?([^.]+).*<->/([^/]+) [NC]

RewriteCond %2<->%3 !^(.*)<->\1$ [NC]

RewriteRule ^(.+) /%2/$1 [PT,L]

what happens if you change it to?

DirectoryIndex index.php index.html index.htm

The same exact thing happens.

Really, I did think of that, and had already tried it. The fact that I can navigate to the directory and have the .htaccess direct me to the .php page is proof that the DirectoryIndex line is not malconstructed.

It is something that is introduced when the subdomain is used.

Well, it seems that the index being searched for is the original index that would have matched had the main server been hit. Right now, the www subdomain has as its index a file called index.html, so i guess when any subdomain is reached, it looks for that for some reason.

Changing that to index.php means that every subdomain is now looking for that filename as the default. So it works.

Can anyone tell me where this behavior is controlled? Is this an effect of the rewrite file i'm using?

Running a google search for what you appear to be wanting to do

( mod-rewrite + subdomain to dir )


where they talked about using mod_alias and talk about
> and the original address of

would permanently redirect to
It's worth a look anyway :>

All the best…


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct