Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking at updating my htaccess file to control a subdomain being created. I am having issues with a few things.

Firstly I am setting up the domain where and that is directing to

I would like it work work like this because I don't want to go through a large process of restructuring the URL routing that is currently setup, and fixing it like this would make it much easier.

I would also like this to work locally on my development machine. So the URL below also works: and the local site redirects to

This means that if I pass parameters after, say :: it would then route to the page

So far I have, but this is just downloading a php file instead of routing any pages.

RewriteCond %{HTTP_HOST} (^local\.|^)m\.domain\.com\.au$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ mobile.php\/mobile$1 [QSA]

I know that the regex for the local or 'nothing' selector is lazy, but I do not think that is what is killing it. Of course I could be wrong.

Any tips or suggestions would be gratefully accepted.

share|improve this question
I managed something a little more simple. > RewriteCond %{REQUEST_FILENAME} !-f > RewriteCond %{HTTP_HOST} (^|^local.)m\.domain\.com\.au$ [NC] > RewriteRule ^(.*)$ mobile.php [QSA,L] – frodosghost Jul 28 '11 at 7:00

It looks like your rule is getting you to a PHP file. I'm not sure what you mean by "downloading a php file" if you mean its downloading the code as plain text then you've likely got a problem with you php handler and not the routing.

Otherwise it probably means that the PHP code is using the original URL to do routing and not your rewritten URL.

What it sounds like you really want to do is have your final rule be a redirect.

So your rules should be something like this.

RewriteCond %{HTTP_HOST} ^(local\.)?m\.domain\.com\.au$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$\/mobile$1 [R=301,QSA]
#I am assuming and and interchangeable
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.