You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by javalishixml <ja...@163.com> on 2015/07/15 18:32:38 UTC
[users@httpd] rewrite rule leads to infinite rewrite loop at apache
Hi Gurus,
Just a silly question this is. But I really suffer it too much ... :(
I'm using rewrite module to do rewrite url. I made below rule:
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP_HOST} ^www.jco.com.cn$
RewriteCond %{REQUEST_URI} ^/myjco/mySecurity
RewriteRule (.*) https://www.jco.com.cn/myjco/mySecurity [L,R]
It works fine. Any access to http://www.jco.com.cn/myjco/mySecurity will rewrite to https://www.jco.com.cn/myjco/mySecurity
But if I make below rule:
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP_HOST} ^rm.jco.com.cn$
RewriteCond %{REQUEST_URI} ^/myjco/orders
RewriteRule (.*) https://rm.jco.com.cn/myjco/orders [L,R]
The browser returns error showing the apache is in an infinite rewrite loop.
I turned on the rewrite module's log to 3 and I got below information:
---------------------------------------------------------------- log ---------------------------------
10.22.11.49 - - [15/Jul/2015:23:35:20 +0800] [rm.jco.com.cn/sid#22d2f58][rid#23567f0/initial] (3) [perdir /jco/WebSite/] applying pattern '(.*)' to uri 'myjco/orders'
10.22.11.49 - - [15/Jul/2015:23:35:20 +0800] [rm.jco.com.cn/sid#22d2f58][rid#23567f0/initial] (3) [perdir /jco/WebSite/] add path info postfix: /jco/WebSite/myjco -> /jco/WebSite/myjco/orders
10.22.11.49 - - [15/Jul/2015:23:35:20 +0800] [rm.jco.com.cn/sid#22d2f58][rid#23567f0/initial] (3) [perdir /jco/WebSite/] strip per-dir prefix: /jco/WebSite/myjco/orders -> myjco/orders
10.22.11.49 - - [15/Jul/2015:23:35:20 +0800] [rm.jco.com.cn/sid#22d2f58][rid#23567f0/initial] (3) [perdir /jco/WebSite/] applying pattern '(.*)' to uri 'myjco/orders'
10.22.11.49 - - [15/Jul/2015:23:35:20 +0800] [rm.jco.com.cn/sid#22d2f58][rid#23567f0/initial] (2) [perdir /jco/WebSite/] rewrite 'myjco/orders' -> 'https://rm.jco.com.cn/myjco/orders'
10.22.11.49 - - [15/Jul/2015:23:35:20 +0800] [rm.jco.com.cn/sid#22d2f58][rid#23567f0/initial] (2) [perdir /jco/WebSite/] explicitly forcing redirect with https://rm.jco.com.cn/myjco/orders
10.22.11.49 - - [15/Jul/2015:23:35:20 +0800] [rm.jco.com.cn/sid#22d2f58][rid#23567f0/initial] (1) [perdir /jco/WebSite/] escaping https://rm.jco.com.cn/myjco/orders for redirect
10.22.11.49 - - [15/Jul/2015:23:35:20 +0800] [rm.jco.com.cn/sid#22d2f58][rid#23567f0/initial] (1) [perdir /jco/WebSite/] redirect to https://rm.jco.com.cn/myjco/orders [REDIRECT/302]
Really weird issue for me. Can you plz do me a favor?
Thanks,
S
[users@httpd] Re:Re: [users@httpd] rewrite rule leads to infinite rewrite loop at
apache
Posted by javalishixml <ja...@163.com>.
Eric,
My below configuration is just going to jump the url from http://rm.jco.com.cn/myjco/orders/xxxx to https://rm.jco.com.cn/myjco/orders/xxxx
But it leads to infinite rewrite loop inside apache
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP_HOST} ^rm.jco.com.cn$
RewriteCond %{REQUEST_URI} ^/myjco/orders
RewriteRule (.*) https://rm.jco.com.cn/myjco/orders [L,R]
Anyother configuration as below showing could successfully jump the url from http://www.jco.com.cn/myjco/mySecurity/xxx to https://www.jco.com.cn/myjco/mySecurityxxx
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP_HOST} ^www.jco.com.cn$
RewriteCond %{REQUEST_URI} ^/myjco/mySecurity
RewriteRule (.*) https://www.jco.com.cn/myjco/mySecurity [L,R]
What's my error in my configuration? How to troubleshooting this issue?
Thanks,
S
At 2015-07-16 00:38:14, "Eric Covener" <co...@gmail.com> wrote:
>On Wed, Jul 15, 2015 at 12:32 PM, javalishixml <ja...@163.com> wrote:
>> RewriteCond %{REQUEST_URI} ^/myjco/mySecurity
>
>
>You probably meant to negate this one, specifically to avoid the loop?
>
>--
>Eric Covener
>covener@gmail.com
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>For additional commands, e-mail: users-help@httpd.apache.org
>
Re: [users@httpd] rewrite rule leads to infinite rewrite loop at apache
Posted by Eric Covener <co...@gmail.com>.
On Wed, Jul 15, 2015 at 12:32 PM, javalishixml <ja...@163.com> wrote:
> RewriteCond %{REQUEST_URI} ^/myjco/mySecurity
You probably meant to negate this one, specifically to avoid the loop?
--
Eric Covener
covener@gmail.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org