I’m using the following rule to redirect domain.com to https://mail.google.com/a/domain.com so my clients can check their mail.
RewriteRule ^mail https://mail.google.com/a/%{HTTP_HOST} [R=301,L,NC]
The problem is www.domain.com ends up at https://mail.google.com/a/www.domain.com which is incorrect. Is there any variable that does not include the www. ? Alternatively, can someone help me stripping it out?
As a tangent issue: Does anyone know of a web tool for testing htaccess files? I encounter a lot of caching problems when testing htaccess and I was thinking a simple simulation environment would be awesome.
Thanks
Use a RewriteCond and match for the the domain name. After that you can backreference it in the RewriteRule, like this:
([^.]+\.[^.]+)$would match the last two sections of your domain, separated by a dot.Edit:
([^.]+(\.|\.co\.)[^.]+)$would match DOMAIN.TLD and DOMAIN.co.TLD too.Edit2:
^e?mailmeans DOMAIN.TLD/mail and DOMAIN.TLD/email would redirectEdit3:
([^.]+(\.|\.co\.|\.com\.)[^.]+)$form DOMAIN.com.TLD, and a bit of correction, was missing a dot.