I need some help on the htaccess subdomain to be pointed to specific file in a folder.
Inside the parent folder should contain individual php files to correctly path the right applications. Sounds simple here.
The url that the user has type should not change / redirect, instead it should only "link" to the correct file at the background
Example when user type userbase.company.com
it should point to
http://company.com/parent/userbase.php
Similarly, when user type userbase2.company.com
it should point to
http://company.com/parent/userbase2.php
but no redirection should happen. url links should remain at
http://userbase2.company.com
folder would be the same, but not the file. Is it possible?
Currently I have this htaccess code:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^userbase.company.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.userbase.company.com$
RewriteRule ^(.*)$ \./parent/userbase.php/$1 [L]
I'm going have to put this at /public_folder/
right? Not at the /public_folder/userbase
?
This rule should do the job:
URL will remain unchanged in browser (means rewrite -- internal redirect).
It will only work for
something.domain.com
(notdomain.com
orwww.domain.com
).It will rewrite this request
http://user1.company.com/hello/pink/kitten.php
into/parent/user1.php/hello/pink/kitten.php
If subdomain is complex (e.g.
www.something.domain.com
) then it will be reflected in rewrite as well: e.g.http://www.something.company.com/hello/pink/kitten.php
will be rewritten to/parent/www.something.php/hello/pink/kitten.php
. If such behaviour is undesired (I do not know your requirements for 100%) then you will need add 1 more condition to the rule.Request for a home page (e.g.
http://user1.company.com/
) will be rewritten in this way:/parent/user1.php/
P.S. Rule was tested before posting -- works fine, but you have to check and maybe tweak it if it needs to be working with your CodeIgniter app (sorry, I'm not familiar with that framework).
In any case this rule should be above your CodeIgniter rewrite rules (if there are such).