Map a second domain name to a specific method
I have two domain names pointing to the same server, example.com and myapp.com. I want all requests to http://example.com/params (with zero or more params) to be equivalent to requesting http://myapp.com/controller/method/params. I don't care whether or not the URL includes "www".
Here is my progress so far. Requests for http://example.com/param are not being rewritten as requests for http://example.c开发者_JAVA技巧om/controller/method/param. To clarify, a request for http://example.com/login takes me to the login page accessible from http://myapp.com/login, not the page accessible from http://myapp.com/controller/method/login. It seems there is something wrong with my first rewrite condition, but I can't figure out what.
RewriteEngine on
RewriteCond %{HTTP_HOST} example.com [NC]
RewriteRule ^(.*)$ controller/method/$1
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [L]
I'm using CodeIgniter which is why I am routing all requests through index.php.
I have been playing around with the code above but have not had any luck. Am I on the right track? Thanks in advance.
Are you missing the forward slash before controller?
RewriteRule ^(.*)$ /controller/method/$1
精彩评论