the_pm
May 18th, 2007, 19:39
Hey everyone,
I'm having a little bit of trouble with a rewrite I'm attempting to do. I'm looking to redirect a non-www URL over to the www version, but without affecting subdomains. The first part is easy. The second part is proving to be a bit of a challenge for me (my Apache scripting knowlegde is not great).
So far, I have:RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]Works great, except subdomains are redirecting. This is bad! I've tried a few things, but so far nothing's worked. My latest attempt was (pretend ignoreme is a subdomain):RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{REQUEST_URI} !ignoreme/
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]Since the subdomain is actually a folder within the site root, I thought this might work. Obviously it didn't. Any ideas what might work here?
I'm having a little bit of trouble with a rewrite I'm attempting to do. I'm looking to redirect a non-www URL over to the www version, but without affecting subdomains. The first part is easy. The second part is proving to be a bit of a challenge for me (my Apache scripting knowlegde is not great).
So far, I have:RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]Works great, except subdomains are redirecting. This is bad! I've tried a few things, but so far nothing's worked. My latest attempt was (pretend ignoreme is a subdomain):RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{REQUEST_URI} !ignoreme/
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]Since the subdomain is actually a folder within the site root, I thought this might work. Obviously it didn't. Any ideas what might work here?