Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED]Apache2 Vhost redirect from http to https issue
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
MrBlc
n00b
n00b


Joined: 16 Mar 2004
Posts: 30

PostPosted: Sat May 14, 2005 4:03 pm    Post subject: [SOLVED]Apache2 Vhost redirect from http to https issue Reply with quote

i want to have certain vhosts rewritten from http://subdomain.domain.tld to https://samesubdomain.domain.tld

i'm no wiz in regexp... :roll:
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
View user's profile Send private message
MrBlc
n00b
n00b


Joined: 16 Mar 2004
Posts: 30

PostPosted: Sat May 14, 2005 4:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
adaptr
Watchman
Watchman


Joined: 06 Oct 2002
Posts: 6730
Location: Rotterdam, Netherlands

PostPosted: Sat May 14, 2005 4:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
MrBlc
n00b
n00b


Joined: 16 Mar 2004
Posts: 30

PostPosted: Sat May 14, 2005 4:40 pm    Post subject: Reply with quote

hah..

you learn something new everyday.. :)

Thanks for the tip..

-MrBlc
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum