Welcome Guest, Not a member yet? Register   Sign In
Dynamic Subdomain with htaccess unchanged URL
#1

I have a Codeigniter project Located at "domain.com/users/abc" directory. I want to access it with Subdomain "abc.domain.com/" and also I don't want the url in the address bar to change.

There will be multiple Codeigniter projects at /var/www/html/users Directory. Each of the sub-directories needs to be accessed via "SubdirectoryName.domain.com".

I have tried virtual hosts configured something like this in my .conf file


Code:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/
UseCanonicalName Off
VirtualDocumentRoot /var/www/html/%1/
ServerName example.com
ServerAlias *.example.com
ErrorLog logs/custom-error_log
CustomLog logs/custom-access_log common
</VirtualHost>

This works fine when routing to the default codeigniter page. Other codeigniter routings do not work. Example, "subdomain.example.com/login" should go to "login" controller. Instead, it looks for a folder named "login" inside "subdomain" folder.

What am I doing wrong?

Both htaccess and apache configuration solutions will be appreciated.

Thanks in Advance.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB