Return-Path: X-Original-To: apmail-httpd-users-archive@www.apache.org Delivered-To: apmail-httpd-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2FF68ED13 for ; Sun, 10 Feb 2013 23:58:25 +0000 (UTC) Received: (qmail 3485 invoked by uid 500); 10 Feb 2013 23:58:22 -0000 Delivered-To: apmail-httpd-users-archive@httpd.apache.org Received: (qmail 3382 invoked by uid 500); 10 Feb 2013 23:58:21 -0000 Mailing-List: contact users-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: users@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list users@httpd.apache.org Received: (qmail 3373 invoked by uid 99); 10 Feb 2013 23:58:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Feb 2013 23:58:21 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of icicimov@gmail.com designates 209.85.215.180 as permitted sender) Received: from [209.85.215.180] (HELO mail-ea0-f180.google.com) (209.85.215.180) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Feb 2013 23:58:17 +0000 Received: by mail-ea0-f180.google.com with SMTP id c1so2411779eaa.39 for ; Sun, 10 Feb 2013 15:57:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=TbCL9nA+iFfCcVR1V2/FKqBtSH50Sjyd+sYJC0vcr14=; b=zmOKgvbklCJgyxJ8ssWnfGP0NzN3hHrNSq3PlRlHmZRAfv1FOxiG43PHkL3P57JL22 EXx3e32ZLhRuE+JzHiF6TFhTvJuIKM9dH/qRikT51934Y9AZNlUZH+k5QuhrlV6Ajsl5 XgZAwvTPtJPKdLh59XYxQDTiMzvj2lXEi84CCq8EGepfWCM8i4Ys+OW5H+jW/Lyw5+OZ gyrouQMSiz+X+4jzQDZM4FTnuSkDkG5HktbsbVsAfS5Nrr04PXjpSEvIKbZOoxi/j0+M FKNnw22VPEWVCZ1FzPvsG61FfIwR7H2t9qFoGD4NHFJWNvQLpWbe/U1AFLARQ4EbiRVn o8cg== MIME-Version: 1.0 X-Received: by 10.14.173.196 with SMTP id v44mr43264702eel.29.1360540676062; Sun, 10 Feb 2013 15:57:56 -0800 (PST) Received: by 10.223.94.66 with HTTP; Sun, 10 Feb 2013 15:57:55 -0800 (PST) Received: by 10.223.94.66 with HTTP; Sun, 10 Feb 2013 15:57:55 -0800 (PST) In-Reply-To: References: Date: Mon, 11 Feb 2013 10:57:55 +1100 Message-ID: From: Igor Cicimov To: users Content-Type: multipart/alternative; boundary=047d7b604368b2fdf704d5678f7f X-Virus-Checked: Checked by ClamAV on apache.org Subject: RE: [users@httpd] Rewrite rules not working --047d7b604368b2fdf704d5678f7f Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable RewriteLog i think was the statement but please check the docs too On 11/02/2013 10:34 AM, "Andrew White" wrote: > Hi Igor,**** > > ** ** > > Thanks for your help, but this doesn=92t seem to work.**** > > ** ** > > From a bit of testing, it looks like the RewriteRule starting with =93/= =94 > simply doesn=92t catch anything.**** > > ** ** > > Any other ideas? Or are there any logs I can check/set up for mod_rewrite= ? > **** > > ** ** > > Thanks all!**** > > ** ** > > Andrew**** > > ** ** > > *From:* Igor Cicimov [mailto:icicimov@gmail.com] > *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 < > andrew@computersforall.com.au> wrote:**** > > Hi all,**** > > I've been writing a rewrite rule to try and redirect all of our traffic > from mysite.com.au to www.mysite.com.au. I also need to conditionally > redirect depending on SSL enabled or not.**** > > I've hacked on a bit from askapache.com to > create a variable that holds either *http* or *https* dependently. Below > is the code I'm using:**** > > **** > > RewriteCond %{HTTPS} =3Don**** > > RewriteRule ^(.+)$ - [env=3Dps:https]**** > > RewriteCond %{HTTPS} !=3Don**** > > RewriteRule ^(.+)$ - [env=3Dps:http]**** > > RewriteCond %{HTTP_HOST} ^mysite\.com\.au(.*)$ [NC]**** > > RewriteCond %{HTTP_HOST} !^$**** > > RewriteRule ^(.*)$ %{ENV:ps}://www.mysite.com.au/$1 [L,R=3D301]**** > > **** > > This works fine for URLs with paths (e.g. mysite.com.au/foo redirects to > www.mysite.com.au/foo) and does the *http* and *https* switch fine.**** > > However when just accessing the domain (just mysite.com.au) it redirects > tohttp://www.mysite.com.au/home/website/public_html/:/www.mysite.com.au/*= * > ** > > I'm sure it's something very small and basic I'm missing - if someone > could point it out, that'd be appreciated.**** > > Thanks!**** > > Andrew**** > > **** > > Try this way > > > **** > > RewriteCond %{HTTP_HOST} ^mysite\.com\.au$ [NC]**** > > RewriteCond %{HTTP_HOST} !^$**** > > RewriteRule ^/(.*)$ %{ENV:ps}://www.mysite.com.au/$1 [L,R=3D301]**** > > ** ** > --047d7b604368b2fdf704d5678f7f Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable

RewriteLog i think was the statement but please check the do= cs too

On 11/02/2013 10:34 AM, "Andrew White"= <andrew@computersforal= l.com.au> wrote:

Hi Igor,

=A0<= /p>

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

=A0<= /p>

From a bit of testing, it= looks like the RewriteRule starting with =93/=94 simply doesn=92t catch an= ything.

=A0<= /p>

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

=A0<= /p>

Thanks all!=

=A0<= /p>

Andrew

=A0<= /p>

From: Igor Cic= imov [mailto:icicim= ov@gmail.com]
Sent: Friday, 8 February 2013 11:26 PM
To: users
Subject: Re: [users@httpd] Rewrite rules not working

=A0

=A0

=A0

On Fri, Feb 8, 2013 at 10:51 AM, Andrew White <andrew@com= putersforall.com.au> wrote:

Hi all,

I've been writing a rewrite rule to try and redirect all of = our traffic from mysite.com.au to www.mysite.com.au. I also need to conditionally redirect depending on S= SL enabled or not.

I've hacked on a bit from=A0askapache.= com=A0to create a variable that holds either=A0http=A0or=A0https=A0dependently. Below is th= e code I'm using:

=A0

=A0=A0=A0 RewriteCond %{HTTPS} =3Don
=A0=A0=A0 RewriteRule ^(.+)$=
 - [env=3Dps:https]
=A0=A0=A0 RewriteCond %{HTTP=
S} !=3Don
=A0=A0=A0 RewriteRule ^(.+)$=
 - [env=3Dps:http]
=A0=A0=A0 RewriteCond %{HTTP=
_HOST} ^mysite\.com\.au(.*)$ [NC]
=A0=A0=A0 RewriteCond %{HTTP=
_HOST} !^$
=A0=A0=A0 RewriteRule ^(.*)$=
 %{ENV:ps}://www.=
mysite.com.au/$1 [L,R=3D301]

=A0

This works fine for URLs with paths (e.g. mysite.com.au/foo redirects to www.mysite.com.a= u/foo) and does the=A0http=A0and=A0https=A0switch fine.

However when just accessing the domain (just mysite.com.au) it re= directs tohttp://www.mysite.com.au/home/website/publi= c_html/:/www.mysite.com.au/

I'm sure it's something very small and basic I'm mis= sing - if someone could point it out, that'd be appreciated.<= /u>

Thanks!

Andrew=

=A0

Try this way


RewriteCond %{HTTP_HOST} ^my=
site\.com\.au$ [NC]
=A0=A0=A0 RewriteCond %{HTTP=
_HOST} !^$
=A0=A0=A0 RewriteRule ^/(.*)=
$ %{ENV:ps}://www=
.mysite.com.au/$1 [L,R=3D301]

=A0

--047d7b604368b2fdf704d5678f7f--