I'm trying to make any or a set of subdomains redirect to a folder inside "controllers" folder of a CI installation. I've tried a bunch of stuff found here on SO but none work for my project or have the same specs I need. Since I am a bit of a noob when it comes to .htaccess so I've figured I might just ask someone more qualified in here. Here are the specs:
- using this awesome .htaccess file as a base
- need to redirect at least this three subdomains (www|admin|api) to /application/controllers/(www|admin|api) equivalent folders
- without loosing the REQUEST_URI (just saying)
- and without actually changing the URL in the address bar
Example: http://api.domain.com/some/uri/segments should internally redirect to CI_installation_folder/application/controllers/api/some/uri/segments
I've tried something like this (and variations):
RewriteCond %{HTTP_HOST} ^(www|admin|api) [NC] RewriteRule ^(.*)$ /%1/$1 [L,R=301] or replaced the RewriteRule with 2 other lines like so:
RewriteCond %{ENV:REDIRECTED} !true RewriteRule ^(.*)$ [L,R=301,E=REDIRECTED:true] to prevent the loop, but all I can get is either a looping redirect (1st case) or even a 500 server error on some variations :(
Adding this
RewriteCond %{REQUEST_URI} !^/(www|admin|api) [NC] will also not work since I'm not changing the URL in the address bar. I also haven't got any success with the [P] flag also.
Can anyone help? Thanks!