Mod-rewrite problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I am using ubunto 8.0.4 and apache 2.2.8 and I'm having some issue with mod rewrite and SSL redirection.

I have two objectives. The first is to redirect http://www.site.co.za and http://site.co.za  to the url https://www.site.co.za and the second is to redirect all traffic for https://site.co.za to https://www.site.co.za.

I can get the first part working perfectly using the following:

<VirtualHost www.site.co.za:80>
ServerName www.site.co.za
ServerAlias site.co.za
DocumentRoot /var/www/site.co.za
ErrorLog /var/log/apache2/site.co.za.co.za-error_log
CustomLog /var/log/apache2/site.co.za-access_log common

RewriteEngine   on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.site.co.za%{REQUEST_URI}
RewriteLog /var/log/apache2/site.co.za-rewrite_log
RewriteLogLevel 3
</VirtualHost>

But for the life of me I cannot get the second part working, I've tried of this:

<VirtualHost www.site.co.za:80>
...
RewriteEngine   on
RewriteCond %{HTTPS} on
RewriteRule (.*) https://www.site.co.za%{REQUEST_URI}
RewriteLog /var/log/apache2/site.co.za-rewrite_log
RewriteLogLevel 3

RewriteEngine   on
RewriteCond %{SERVER_PORT} ^443$
RewriteRule (.*) https://www.site.co.za%{REQUEST_URI}
RewriteLog /var/log/apache2/site.co.za-rewrite_log
RewriteLogLevel 3
</VirtualHost>

and this:

<VirtualHost www.site.co.za:443>
...
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteLog /var/log/apache2/ssl-site.co.za-rewrite_log
RewriteLogLevel 3
</VirtualHost>

I've even add this to the .htaccess file in  /var/www/site.co.za  but still no joy:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteLog /var/log/apache2/ssl-site.co.za-rewrite_log

For some strange reason mod-rewrite seems to be ignoring the SSL traffic even when I remove all rules except for the SSL https://site.co.za to https://www.site.co.za rewrite rule and when I tryhttps://site.co.za I get nothing in the rewrite log files.

Any ideas?

Thanks

[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux