Background
I have a CakePHP application that lives in /m/. I want to write a root level file .htaccessthat redirects the "subdomains" for the site as parameters for actions.
For example: I want to write a rewrite rule that will lead to redirects like this -
http://mysite.myserver.com → http://myserver.com/m/mysite/http://mysite.myserver.com/home → http://myserver.com/m/mysite/homehttp://mysite.myserver.com/foo/bar?baz=true → http://myserver.com/m/mysite/foo/bar?baz=true
Ideally, this redirect should be invisible to users (I don't want to use 301 because I don't want to change the URL).
Here is my current attempt:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)\.myserver\.com$ [NC]
RewriteRule ^(.*)$ http://myserver.com/m/%1/$1 [L]
</IfModule>
As far as I can tell, the main problem is $_SERVER['REQUEST_URI']:
- If I just look through
http://myserver.com/m/mysite/home, $_SERVER['REQUEST_URI'] = /m/mysite/home. - If I move to
http://mysite.myserver.com/homeusing the file .htaccessabove $_SERVER['REQUEST_URI'] = /home.
Problem
- $_SERVER['REQUEST_URI'] : /home, /m/mysite/home .
? ?