Forum Moderators: phranque

Message Too Old, No Replies

need help with subdomain rewriting

         

machonemedia

7:02 pm on Feb 21, 2008 (gmt 0)

10+ Year Member



Hi,

I tried adding some code based on what jdMorgan showed me but it gave me a 500 internal error for my whole site.

Here is my code:

RewriteEngine on

RewriteCond %{HTTP_HOST} !^(www\.)example.com$ [NC]
RewriteCond %{HTTP_HOST} !^(.*)\.example.com$ [NC]
RewriteRule ^ [%{HTTP_HOST}%{REQUEST_URI}...] [L,R=301]

RewriteCond %{HTTP_HOST} ^(.*)\.example\.com [E=company:%1] [NC]

RewriteRule ^schedule/$ schedule.php [NC]
RewriteRule ^schedule/([0-9]+)/([0-9]+)/$ schedule.php?yearID=$1&monthID=$2&company=%{ENV:company} [NC]

RewriteRule ^day/$ day.php [NC]
RewriteRule ^day/([0-9]+)/([0-9]+)/([0-9]+)/$ day.php?yearID=$1&monthID=$2&dayID=$3&company=%{ENV:company} [NC]

RewriteRule ^profile/([0-9]+)/$ profile.php?id=$1&company=%{ENV:company} [NC]
RewriteRule ^profile/([0-9]+)/([0-9]+)/$ profile.php?id=$1&nw=$2&company=%{ENV:company} [NC]

RewriteRule ^profile/([0-9]+)/([0-9]+)/([0-9]+)/([0-9]+)/$ profile.php?id=$1&nw=$2&yearID=$3&monthID=$4&company=%{ENV:company} [NC]

RewriteRule ^profile/([0-9]+)/([0-9]+)/([0-9]+)/$ /profile/$1/ [R]
RewriteRule ^profile/([0-9]+)/([0-9]+)/$ /profile/$1/ [R]
RewriteRule ^profile/([0-9]+)/$ /profile/$1/ [R]

RewriteRule ^account/$ /account/profile/ [R]
RewriteRule ^account/([a-zA-Z]+)/$ account.php?s=$1&company=%{ENV:company} [NC]
RewriteRule ^account/([a-zA-Z]+)/([a-zA-Z]+)/$ account.php?s=$1&a=$2&company=%{ENV:company} [NC]

RewriteRule ^people/$ people.php?company=%{ENV:company} [NC]
RewriteRule ^sitemap/$ sitemap.php [NC]
RewriteRule ^login/$ login.php?company=%{ENV:company} [NC]
RewriteRule ^logout/$ logout.php?company=%{ENV:company} [NC]
RewriteRule ^sign-up/$ signup.php [NC]
RewriteRule ^contact/$ contact.php [NC]
RewriteRule ^subscribed/$ subscribed.php [NC]

# Redirect main page to login page if accessed
RewriteCond %{HTTP_HOST} !^(www\.)example.com$ [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.example.com$
RewriteRule ^(/)?$ /login/ [R]

I also tried this line as jdMorgan's original syntax (with the dash),

RewriteCond %{HTTP_HOST} ^(.*)\.example\.com - [E=company:%1] [NC]

Any help is appreciated, this is the one thing holding my site back :(

Thanks,
Bryan

jdMorgan

5:43 pm on Feb 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is invalid:

RewriteCond %{HTTP_HOST} ^(.*)\.example\.com [E=company:%1] [NC]

RewriteConds do not take action; They only establish a condition under which the single following rewriterule will be invoked. Also, flags must be combined, when needed, inside one pair of brackets.

Taking a guess at what you want, try:


RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com [NC]
RewriteRule .* - [E=company:%1]

Jim