httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew White <>
Subject RE: [users@httpd] Rewrite rules not working
Date Sun, 10 Feb 2013 23:32:16 GMT
Hi Igor,

Thanks for your help, but this doesn't seem to work.

>From a bit of testing, it looks like the RewriteRule starting with "/" simply doesn't
catch anything.

Any other ideas? Or are there any logs I can check/set up for mod_rewrite?

Thanks all!


From: Igor Cicimov []
Sent: Friday, 8 February 2013 11:26 PM
To: users
Subject: Re: [users@httpd] Rewrite rules not working

On Fri, Feb 8, 2013 at 10:51 AM, Andrew White <<>>

Hi all,

I've been writing a rewrite rule to try and redirect all of our traffic from<>
to<>. I also need to conditionally redirect
depending on SSL enabled or not.

I've hacked on a bit from<>
to create a variable that holds either http or https dependently. Below is the code I'm using:

    RewriteCond %{HTTPS} =on

    RewriteRule ^(.+)$ - [env=ps:https]

    RewriteCond %{HTTPS} !=on

    RewriteRule ^(.+)$ - [env=ps:http]

    RewriteCond %{HTTP_HOST} ^mysite\.com\.au(.*)$ [NC]

    RewriteCond %{HTTP_HOST} !^$

    RewriteRule ^(.*)$ %{ENV:ps}://$1<$1>

This works fine for URLs with paths (e.g.<>
redirects to<>) and does the http
and https switch fine.

However when just accessing the domain (just<>) it
redirects to

I'm sure it's something very small and basic I'm missing - if someone could point it out,
that'd be appreciated.



Try this way

RewriteCond %{HTTP_HOST} ^mysite\.com\.au$ [NC]

    RewriteCond %{HTTP_HOST} !^$

    RewriteRule ^/(.*)$ %{ENV:ps}://$1<$1>

View raw message