httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Igor Cicimov <icici...@gmail.com>
Subject RE: [users@httpd] Rewrite rules not working
Date Mon, 11 Feb 2013 00:55:18 GMT
To have ssl teaffic you need ssl vhost configured. Do you have it? Also
please explain where have you put the rules and show us the detailed
config. Sorry for top posting im on the phone.
On 11/02/2013 11:46 AM, "Andrew White" <andrew@computersforall.com.au>
wrote:

>  Hey Igor,****
>
> ** **
>
> Thanks for that.****
>
> ** **
>
> I’ve turned it on and I think I’ve identified the problem, however I still
> can’t quite find a fix. In the logs if I am using my original
> condition/rule and use mysite.com.au/test I see the following:****
>
> ** **
>
> 10.1.1.1 - - [11/Feb/2013:11:37:50 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b847d100/initial<http://mysite.com.au/sid#b81d24f8][rid%23b847d100/initial>]
> (3) [perdir /home/website/public_html/] strip per-dir prefix:
> /home/website/public_html/test -> test****
>
> 10.1.1.1 - - [11/Feb/2013:11:37:50 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b847d100/initial<http://mysite.com.au/sid#b81d24f8][rid%23b847d100/initial>]
> (3) [perdir /home/website/public_html/] applying pattern '^(.+)$' to uri
> 'test'****
>
> 10.1.1.1 - - [11/Feb/2013:11:37:50 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b847d100/initial<http://mysite.com.au/sid#b81d24f8][rid%23b847d100/initial>]
> (3) [perdir /home/website/public_html/] strip per-dir prefix:
> /home/website/public_html/test -> test****
>
> 10.1.1.1 - - [11/Feb/2013:11:37:50 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b847d100/initial<http://mysite.com.au/sid#b81d24f8][rid%23b847d100/initial>]
> (3) [perdir /home/website/public_html/] applying pattern '^(.+)$' to uri
> 'test'****
>
> 10.1.1.1 - - [11/Feb/2013:11:37:50 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b847d100/initial<http://mysite.com.au/sid#b81d24f8][rid%23b847d100/initial>]
> (3) [perdir /home/website/public_html/] strip per-dir prefix:
> /home/website/public_html/test -> test****
>
> 10.1.1.1 - - [11/Feb/2013:11:37:50 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b847d100/initial<http://mysite.com.au/sid#b81d24f8][rid%23b847d100/initial>]
> (3) [perdir /home/website/public_html/] applying pattern '^(.*)$' to uri
> 'test'****
>
> 10.1.1.1 - - [11/Feb/2013:11:37:50 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b847d100/initial<http://mysite.com.au/sid#b81d24f8][rid%23b847d100/initial>]
> (2) [perdir /home/website/public_html/] rewrite 'test' -> '
> http://www.mysite.com.au/test'****
>
> 10.1.1.1 - - [11/Feb/2013:11:37:50 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b847d100/initial<http://mysite.com.au/sid#b81d24f8][rid%23b847d100/initial>]
> (2) [perdir /home/website/public_html/] explicitly forcing redirect with
> http://www.mysite.com.au/test****
>
> ** **
>
> However when I run it against just mysite.com.au I see:****
>
> ** **
>
> 10.1.1.1 - - [11/Feb/2013:11:38:16 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b845bc18/initial<http://mysite.com.au/sid#b81d24f8][rid%23b845bc18/initial>]
> (3) [perdir /home/website/public_html/] strip per-dir prefix:
> /home/website/public_html/ ->****
>
> 10.1.1.1 - - [11/Feb/2013:11:38:16 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b845bc18/initial<http://mysite.com.au/sid#b81d24f8][rid%23b845bc18/initial>]
> (3) [perdir /home/website/public_html/] applying pattern '^(.+)$' to uri ''
> ****
>
> 10.1.1.1 - - [11/Feb/2013:11:38:16 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b845bc18/initial<http://mysite.com.au/sid#b81d24f8][rid%23b845bc18/initial>]
> (3) [perdir /home/website/public_html/] strip per-dir prefix:
> /home/website/public_html/ ->****
>
> 10.1.1.1 - - [11/Feb/2013:11:38:16 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b845bc18/initial<http://mysite.com.au/sid#b81d24f8][rid%23b845bc18/initial>]
> (3) [perdir /home/website/public_html/] applying pattern '^(.+)$' to uri ''
> ****
>
> 10.1.1.1 - - [11/Feb/2013:11:38:16 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b845bc18/initial<http://mysite.com.au/sid#b81d24f8][rid%23b845bc18/initial>]
> (3) [perdir /home/website/public_html/] strip per-dir prefix:
> /home/website/public_html/ ->****
>
> 10.1.1.1 - - [11/Feb/2013:11:38:16 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b845bc18/initial<http://mysite.com.au/sid#b81d24f8][rid%23b845bc18/initial>]
> (3) [perdir /home/website/public_html/] applying pattern '^(.*)$' to uri ''
> ****
>
> 10.1.1.1 - - [11/Feb/2013:11:38:16 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b845bc18/initial<http://mysite.com.au/sid#b81d24f8][rid%23b845bc18/initial>]
> (2) [perdir /home/website/public_html/] rewrite '' -> '://
> www.mysite.com.au/'****
>
> 10.1.1.1 - - [11/Feb/2013:11:38:16 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b845bc18/initial<http://mysite.com.au/sid#b81d24f8][rid%23b845bc18/initial>]
> (3) [perdir /home/website/public_html/] add per-dir prefix: ://
> www.mysite.com.au/ -> /home/website/public_html/://www.mysite.com.au/****
>
> 10.1.1.1 - - [11/Feb/2013:11:38:16 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b845bc18/initial<http://mysite.com.au/sid#b81d24f8][rid%23b845bc18/initial>]
> (2) [perdir /home/website/public_html/] explicitly forcing redirect with
> http:/.makeitmine.com.au/home/website/public_html/://www.mysite.com.au/***
> *
>
> ** **
>
> Note that the environment variable I’m trying to set (SSL on/off) isn’t
> being set. As such, it’s not seeing the http/https prefix and assuming it’s
> a relative internal path!****
>
> ** **
>
> When I’m trying to set the environment variable, I use the following code:
> ****
>
> ** **
>
>        RewriteCond %{HTTPS} =on****
>
>         RewriteRule ^(.+)$ - [env=ps:https]****
>
>         RewriteCond %{HTTPS} !=on****
>
>         RewriteRule ^(.+)$ - [env=ps:http] ****
>
> ** **
>
> The RegEx of ^(.+)$ expects a *minimum* of 1 character, which there is
> not to match! I modified it as follows:****
>
> ** **
>
>        RewriteCond %{HTTPS} =on****
>
>         RewriteRule ^(.*)$ - [env=ps:https]****
>
>         RewriteCond %{HTTPS} !=on****
>
>         RewriteRule ^(.*)$ - [env=ps:http] ****
>
> ** **
>
> And now it matches, even on 0 characters!****
>
> ** **
>
> Thanks again for your help, problem solved :)****
>
> ** **
>
> 10.1.1.1 - - [11/Feb/2013:11:44:57 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b8478208/initial<http://mysite.com.au/sid#b81d24f8][rid%23b8478208/initial>]
> (3) [perdir /home/website/public_html/] strip per-dir prefix:
> /home/website/public_html/ ->****
>
> 10.1.1.1 - - [11/Feb/2013:11:44:57 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b8478208/initial<http://mysite.com.au/sid#b81d24f8][rid%23b8478208/initial>]
> (3) [perdir /home/website/public_html/] applying pattern '^(.*)$' to uri ''
> ****
>
> 10.1.1.1 - - [11/Feb/2013:11:44:57 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b8478208/initial<http://mysite.com.au/sid#b81d24f8][rid%23b8478208/initial>]
> (3) [perdir /home/website/public_html/] strip per-dir prefix:
> /home/website/public_html/ ->****
>
> 10.1.1.1 - - [11/Feb/2013:11:44:57 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b8478208/initial<http://mysite.com.au/sid#b81d24f8][rid%23b8478208/initial>]
> (3) [perdir /home/website/public_html/] applying pattern '^(.*)$' to uri ''
> ****
>
> 10.1.1.1 - - [11/Feb/2013:11:44:57 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b8478208/initial<http://mysite.com.au/sid#b81d24f8][rid%23b8478208/initial>]
> (3) [perdir /home/website/public_html/] strip per-dir prefix:
> /home/website/public_html/ ->****
>
> 10.1.1.1 - - [11/Feb/2013:11:44:57 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b8478208/initial<http://mysite.com.au/sid#b81d24f8][rid%23b8478208/initial>]
> (3) [perdir /home/website/public_html/] applying pattern '^(.*)$' to uri ''
> ****
>
> 10.1.1.1 - - [11/Feb/2013:11:44:57 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b8478208/initial<http://mysite.com.au/sid#b81d24f8][rid%23b8478208/initial>]
> (2) [perdir /home/website/public_html/] rewrite '' -> '
> http://www.mysite.com.au/'****
>
> 10.1.1.1 - - [11/Feb/2013:11:44:57 +1100] [
> mysite.com.au/sid#b81d24f8][rid#b8478208/initial<http://mysite.com.au/sid#b81d24f8][rid%23b8478208/initial>]
> (2) [perdir /home/website/public_html/] explicitly forcing redirect with
> http://www.mysite.com.au/****
>
> ** **
>
> *From:* Igor Cicimov [mailto:icicimov@gmail.com]
> *Sent:* Monday, 11 February 2013 10:58 AM
> *To:* users
> *Subject:* RE: [users@httpd] Rewrite rules not working****
>
> ** **
>
> RewriteLog i think was the statement but please check the docs too****
>
> On 11/02/2013 10:34 AM, "Andrew White" <andrew@computersforall.com.au>
> wrote:****
>
> 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!****
>
>  ****
>
> 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<http://www.askapache.com/htaccess/http-https-rewriterule-redirect.html>
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}://www.mysite.com.au/$1 [L,R=301]****
>
>   ****
>
> 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=301]****
>
>  ****
>

Mime
View raw message