I'm attempting to get a redirect which is failing, and for some reason I can't think today. I have a vHost file within HTTPD that listens on standard port 80 and port 443. I'm attempting to redirect https://domain.com/(.*) to https://www.domain.com/$1 so that the URL remains intact.
My config is as follows:
ServerName www.domain.com
ServerAlias tempdomain.testdomain.co.uk
ServerAlias domain.com
My rerwrite rule I'm using is.
RewriteCond %{HTTP_HOST} ^domain\.com$
RewriteRule ^(.*)$ https://www.domain.com$1 [R=301,L]
I've also tried removing the \. and $ but nothing.. When I visit the url https://domain.com/secure.page?action=comp it doesn't redirect to https://www.domain.com/secure.page?action=comp
I do also have other SSL pages, the above was just an example..
Can anyone point out my stupidity.
Best Answer
I can't see anything wrong with your rewrite rule. Are you sure :
has been specified and this config is definitely being executed? Is it in a .htaccess file?
Try setting up a rewrite log it can help:
http://www.latenightpc.com/blog/archives/2007/09/05/a-couple-ways-to-debug-mod_rewrite