Saturday, December 13, 2014

linux - Redirect non-www ssl traffic to www ssl (apache)

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.

No comments:

Post a Comment