Welcome Guest, Not a member yet? Register   Sign In
htaccess & subdomains
#1

[eluser]Unknown[/eluser]
I am having issues - we have two domains working off the same codeignitor installation. I'm doing to use "domain" instead of our real domain bc we aren't live yet.

www.domain.com points to the root directory.

members.domain.com points to a subfolder called /members/

We have an htaccess file in the root with this
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|media|pdf|js|css|members)
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]

The www site works fine on every page.

The members.domain.com only works on the initial page. Any sub pages (like http://members.domain.com/plan/view/5) do not work, I get a "Not Found" error.

Any ideas?
#2

[eluser]rogierb[/eluser]
You need a second .htaccess in the member folder with a RewriteBase /members/
#3

[eluser]Unknown[/eluser]
Thanks for the quick response!

I had already tried doing that like this:
Code:
RewriteEngine on
RewriteBase /members
RewriteCond $1 !^(index\.php|images|robots\.txt|media|pdf|js|css)
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]

Because of your post, I researched RewriteBase a bit harder and discovered what I was doing wrong. The RewriteBase removes the physical directory, so it works like this:
Code:
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|images|robots\.txt|media|pdf|js|css)
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]

Thank you so much!
#4

[eluser]Steiner[/eluser]
I managed to get my server to utilize domains as an user relatable sub-query.

Code:
#Options are Optional
Options -Indexes

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule ^(.*) http://www.domain.com/$1 [R=301,L]

#...rewrite rules related to the www version of the domain go here
RewriteCond %{HTTP_HOST} ^www\.domain\.com
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

#The below rules should apply to any non WWW pages, such as subdomain.domain.com
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com$
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt)
RewriteRule ^(.*)$ /index.php/user/%1 [L]

Sadly if you goto http://domain.com it will redirect to http://www.domain.com; I can't find away around it without compromising the user sub-query. But it should help some readers.

This will allow normal use of the www.domain.com/segment/segments applications while http://testuser.domain.com/segment will literally seek out the path equivilent of http://domain.com/index.php/users/username/<username> or whatever you have setup in your configuration.

This also requires that you setup routing:
Code:
$route['user/(:any)'] = 'user/username/$1';
Only a concept, there are other solutions, this one just works best for me.




Theme © iAndrew 2016 - Forum software by © MyBB