1

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 http://m.domain.com/ and that is directing to http://www.domain.com/mobile.php/mobile

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: http://local.m.domain.com and the local site redirects to http://local.domain.com/mobile.php/mobile

This means that if I pass parameters after, say :: http://m.domain.com/page it would then route to the page http://www.domain.com/mobile.php/mobile/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.

frodosghost
  • 111
  • 3
  • 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 07:00

1 Answers1

0

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 ^(.*)$ http://%1.domain.com/mobile.php\/mobile$1 [R=301,QSA]
#I am assuming www.domain.com and domain.com and interchangeable
matthew
  • 1,319
  • 1
  • 11
  • 21