Dynamic subdomains not allowing access to other files

Using a single web hosting account to host multiple sites

Dynamic subdomains not allowing access to other files

Postby newelement » Fri Feb 13, 2009 7:56 am

I'm forwarding subdomains to a certain page. The problem is it won't give me access to other pages outside that. For example if I try to go to login.php. This is what I have so far

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(mydomain\.com)$ [NC]
RewriteRule .* http://www.%1%{REQUEST_URI} [R=301]

RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$ [NC]
RewriteRule .* - [L] 

RewriteCond %{HTTP_HOST} ^(^.*)\.mydomain.com
RewriteRule (.*)  company.php?company=%1 [QSA,L]
newelement
 
Posts: 6
Joined: Fri Feb 13, 2009 7:45 am

Postby richardk » Sun Feb 15, 2009 11:13 am

Examples would be helpful. Do you mean company.example.com/login.php does not work?
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(example\.com)$ [NC]
RewriteRule .* http://www.%1%{REQUEST_URI} [R=301]

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule .* - [L]

RewriteCond %{HTTP_HOST} ^(.+)\.example.com$ [NC]
RewriteRule ^$ /company.php?company=%1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby newelement » Sun Feb 15, 2009 11:44 am

Correct. dynamic.domain.com/login.php keeps going to company.php

The small change you made works. Thanks a lot. I wish I knew mod rewrites as well as you.
newelement
 
Posts: 6
Joined: Fri Feb 13, 2009 7:45 am

Postby richardk » Sun Feb 15, 2009 12:30 pm

Code: Select all
[R=301]

should be
Code: Select all
[R=301,L]

because you want it to stop processing rules straight away.

Code: Select all
^$

only matches requests to / instead of
Code: Select all
(.*)

that matches /anything_(including_nothing).
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 4 guests

cron