View previous topic :: View next topic |
Author |
Message |
MrBlc n00b
Joined: 16 Mar 2004 Posts: 30
|
Posted: Sat May 14, 2005 4:03 pm Post subject: [SOLVED]Apache2 Vhost redirect from http to https issue |
|
|
i want to have certain vhosts rewritten from http://subdomain.domain.tld to https://samesubdomain.domain.tld
i'm no wiz in regexp...
this is what i have managed to boil together so far, although it's not working..
Code: |
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteOptions inherit
RewriteCond %{HTTP_HOST} .webmail*
RewriteCond %{HTTP_HOST} !webmail\.domain\.tld
RewriteRule /(.*) https://webmail.domain.tld/$1 [L,R]
</IfModule>
|
anyone have a better suggestion?
-MrBlc
Last edited by MrBlc on Sat May 14, 2005 4:31 pm; edited 1 time in total |
|
Back to top |
|
|
MrBlc n00b
Joined: 16 Mar 2004 Posts: 30
|
Posted: Sat May 14, 2005 4:31 pm Post subject: |
|
|
funny how a little searching around gets you on the right track..
this is what i ended up with:
Code: |
<VirtualHost *:80>
Servername webmail.domain.tld
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" vcommon
CustomLog logs/access_log.webmail vcommon
DocumentRoot /path/to/webarea/webmail
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://%{SERVER_NAME} [R,L]
</IfModule>
</VirtualHost>
|
which i found out was the best choice since then it won't even touch the mod_ssl unless it enters that vhost..
thanks gentoo forum users.
-MrBlc |
|
Back to top |
|
|
adaptr Watchman
Joined: 06 Oct 2002 Posts: 6730 Location: Rotterdam, Netherlands
|
Posted: Sat May 14, 2005 4:36 pm Post subject: |
|
|
Oh man you're definitely taking the long way around...
Much better: use vhosts themselves to do your redirection.
Make a vhost for http and one for https, then simply set a global redirect from the port 80 vhost to https.
The server will take care of the rest.
Code: | <Vhost *:80>
ServerName yourdomain.com
Redirect / https://yourdomain.com/
</>
<Vhost *:443>
ServerName yourdomain.com
DocumentRoot /whatever
</> |
Check it out _________________ >>> emerge (3 of 7) mcse/70-293 to /
Essential tools: gentoolkit eix profuse screen |
|
Back to top |
|
|
MrBlc n00b
Joined: 16 Mar 2004 Posts: 30
|
Posted: Sat May 14, 2005 4:40 pm Post subject: |
|
|
hah..
you learn something new everyday..
Thanks for the tip..
-MrBlc |
|
Back to top |
|
|
|