Multiple Subdomain Redirects

So Basically, I wrote the code below, since I wanted to use subdomains with my domain name to redirect me to external sites.


RewriteCond %{HTTP_HOST} ^calendar.domain.com
RewriteRule ^(.*)$ https://www.google.com/calendar/XXXXXXXXXXXXXX [R] 

RewriteCond %{HTTP_HOST} ^mail.domain.com
RewriteRule ^(.*)$ http://mail.google.com/a/XXXXXXXXXX [R] 

RewriteCond %{HTTP_HOST} ^google.domain.com
RewriteRule ^(.*)$ https://www.google.com/a/CONTROLPANEL [R] 

RewriteCond %{HTTP_HOST} ^WP.domain.com
RewriteRule ^(.*)$ http://domain.com/wordpress/wp-admin/ [R] 

RewriteCond %{HTTP_HOST} ^stats.domain.com
RewriteRule ^(.*)$ http://my.statcounter.com/XXXXXXXXXXXXXXXXXXX [R] 

RewriteCond %{HTTP_HOST} ^docs.domain.com
RewriteRule ^(.*)$ https://www.google.com/a/domain.com/ [R] 

RewriteCond %{HTTP_HOST} ^sites.domain.com
RewriteRule ^(.*)$ http://sites.google.com/a/domain.com [R] 


So the first two (Mail and calendar seem to work). the rest, I seem to get a “server not found” aka problem loading page error. What am I doing wrong? Can someone help me?

I have tried it with [R] and [R,L]…

PW,

Comments (okay, QUESTIONS):

  • WHY are you not escaping the dot characters in your regex for {HTTP_HOST}?
  • WHAT do you think the Redirect flag is doing for you?
  • WHY are you capturing the {REQUEST_URI} if you’re not going to do anything with it?

RewriteCond %{HTTP_HOST} ^calendar[COLOR="Red"]\\[/COLOR].domain[COLOR="Red"]\\[/COLOR].com[COLOR="Red"]$[/COLOR]
RewriteRule ^[COLOR="Red"](.*)[/COLOR]$ https://www.google.com/calendar/XXXXXXXXXXXXXX[COLOR="Red"] [R][/COLOR] 

RewriteCond %{HTTP_HOST} ^mail.domain.com
RewriteRule ^(.*)$ http://mail.google.com/a/XXXXXXXXXX [R] 

RewriteCond %{HTTP_HOST} ^google.domain.com
RewriteRule ^(.*)$ https://www.google.com/a/CONTROLPANEL [R] 

RewriteCond %{HTTP_HOST} ^WP.domain.com
RewriteRule ^(.*)$ http://domain.com/wordpress/wp-admin/ [R] 

RewriteCond %{HTTP_HOST} ^stats.domain.com
RewriteRule ^(.*)$ http://my.statcounter.com/XXXXXXXXXXXXXXXXXXX [R] 

RewriteCond %{HTTP_HOST} ^docs.domain.com
RewriteRule ^(.*)$ https://www.google.com/a/domain.com/ [R] 

RewriteCond %{HTTP_HOST} ^sites.domain.com
RewriteRule ^(.*)$ http://sites.google.com/a/domain.com [R]

Other than the obvious (see the questions above - and why you’ve not specified the END anchor on the {HTTP_HOST} RewriteConds), I have to assume that your links are correct.

Regards,

DK