You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "David J. Wells" <dw...@dormanproducts.com> on 2006/08/28 22:05:49 UTC

[users@httpd] mod_rewrite

Hello,
 
I am attempting to redirect traffic for 1 vhost only to https and allow
http to another... I'm trying to do this with mod_rewrite and having no
success. Any suggestions?  See code below: 
 
# This one we want http access to
<VirtualHost otherdomain.com>
   ServerName www.otherdomain.com
   DocumentRoot /var/www/html
</VirtualHost>
 

# this one we want https to
<VirtualHost servername:80>
    ServerName www.servername.com
    DocumentRoot /var/www/html
    <Directory /var/www/html>
        AllowOverride All
        RewriteEngine On
        RewriteCond %{SERVER_PORT} !^443$
        RewriteRule (.*) https://%{SERVER_NAME}$1 [L,R]
    </Directory>
</VirtualHost>
 
#SSL.conf
<VirtualHost _default_:443>
DocumentRoot "/var/www/html"
ServerName www.servername.com:443
[ssl stuff]
</VirtualHost>





CONFIDENTIALITY NOTE
The information transmitted is intended only for the person or 
entity to which it is addressed and may contain confidential 
and/or privileged material.  Any review, retransmission, 
dissemination or other use of, or taking of any action in 
reliance 
upon, this information by persons or entities other than the 
intended 
recipient is prohibited. If you received this in error, please 
contact the sender and delete the material from any computer.

Re: [users@httpd] mod_rewrite

Posted by Joshua Slive <jo...@slive.ca>.
On 8/28/06, David J. Wells <dw...@dormanproducts.com> wrote:
>
>
> Hello,
>
> I am attempting to redirect traffic for 1 vhost only to https and allow http
> to another… I'm trying to do this with mod_rewrite and having no success.
> Any suggestions?  See code below:
>
> # This one we want http access to
> <VirtualHost otherdomain.com>
>    ServerName www.otherdomain.com
>    DocumentRoot /var/www/html
> </VirtualHost>
>
>
> # this one we want https to
> <VirtualHost servername:80>
>     ServerName www.servername.com
>     DocumentRoot /var/www/html
>     <Directory /var/www/html>
>         AllowOverride All
>         RewriteEngine On
>         RewriteCond %{SERVER_PORT} !^443$
>         RewriteRule (.*) https://%{SERVER_NAME}$1 [L,R]
>     </Directory>
> </VirtualHost>
>
> #SSL.conf
> <VirtualHost _default_:443>
> DocumentRoot "/var/www/html"
> ServerName www.servername.com:443
> [ssl stuff]
> </VirtualHost>

First, your non-ssl virtual hosts are using name-based
virtual-hosting, but you aren't doing it correctly.  You need to
follow the example at:
http://httpd.apache.org/docs/2.2/vhosts/name-based.html#using

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org