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 (test.domain.com) they are transparently directed to domain.com/test/. 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 domain.com/test/, the index loads fine. When I go through test.domain.com, 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.)?callsteward.com$ [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 )

Yielded:

http://www.webmasterworld.com/apache/3448467.htm

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

http://wiki.example.com/

would permanently redirect to

http://www.example.com/wiki/
It's worth a look anyway :>

All the best…

Reply

Please enter an answer
Tips:

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] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct