Quote:
Originally Posted by mahmoud
Hi
i want to setup my ssl vhost and i have a bit of a problem
first i want to redirect the links to home page if its not secure
e.g
http://secure.myserver.com should go back to http://myserver.com
but
https://secure.myserver.com should stay on https://secure.myserver.com
and when on the https or secure link if they leave the pages that are secure they should be redirected back to http://myserver.com
i am using fedora 9 64bit
also i have alot of rewrites in there for the alias domains i have and i want it to affect all the
|
You can use HTTP_HOST , SERVER_PORT in rewrite conditions to do this.
for e.g.
RewriteCond %{HTTP_HOST} !^secure\.myserver\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) http://myserver.com/$1 [L,R]
This example should redirect all insecure url which math HTTP_HOST secure.myserver.com to
http://myserver.com. you can add [OR] to add multiple conditions for HTTP_HOST.
You can use following rewrite rule to redirect all insecure URL's to secure without changing the HTTP_HOST(domain in URL) or REQUESTED_URL (files / URL requested)
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]