Avoid endless loop of mod_rewrite
Hi all
A rule is in place that that rewrites domains to www.domains
In one particular home dir, I need the opposite,
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
But it goes into an endless loop that eventually makes firefox spit
'The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for
this address in a way that will never complete.'
How to ignore the higher level rule?
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org
Re: Avoid endless loop of mod_rewrite
--0016367b6d5e5cbb6f048143a924
Content-Type: text/plain; charset=ISO-8859-1
Try using the following to stop the endless loops:
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
Igor
On Mon, Mar 8, 2010 at 4:17 PM, Michael Menegakis <arxeio [at] gmail.com> wrote:
> Hi all
>
> A rule is in place that that rewrites domains to www.domains
>
> In one particular home dir, I need the opposite,
>
> RewriteEngine On
> RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
> RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
>
> But it goes into an endless loop that eventually makes firefox spit
>
> 'The page isn't redirecting properly
> Firefox has detected that the server is redirecting the request for
> this address in a way that will never complete.'
>
> How to ignore the higher level rule?
>
> ------------------------------------------------------------ ---------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
> " from the digest: users-digest-unsubscribe [at] httpd.apache.org
> For additional commands, e-mail: users-help [at] httpd.apache.org
>
>
--0016367b6d5e5cbb6f048143a924
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Try using the following to stop the endless loops:<br><br>RewriteCond %{ENV=
:REDIRECT_STATUS} 200<br>RewriteRule .* - [L]<br><br>Igor<br><br><div class=
=3D"gmail_quote">On Mon, Mar 8, 2010 at 4:17 PM, Michael Menegakis <span di=
r=3D"ltr"><<a href=3D"mailto:arxeio [at] gmail.com">arxeio [at] gmail.com</a>><=
/span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin: 0pt 0pt 0pt 0.8ex; borde=
r-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi all<br>
<br>
A rule is in place that that rewrites domains to www.domains<br>
<br>
In one particular home dir, I need the opposite,<br>
<br>
RewriteEngine On<br>
RewriteCond %{HTTP_HOST} ^<a href=3D"http://www.domain.com" target=3D"_blan=
k">www.domain.com</a>$ [NC]<br>
RewriteRule ^(.*)$ <a href=3D"http://domain.com/$1" target=3D"_blank">http:=
//domain.com/$1</a> [R=3D301,L]<br>
<br>
But it goes into an endless loop that eventually makes firefox spit<br>
<br>
'The page isn't redirecting properly<br>
Firefox has detected that the server is redirecting the request for<br>
this address in a way that will never complete.'<br>
<br>
How to ignore the higher level rule?<br>
<br>
------------------------------------------------------------ ---------<br>
The official User-To-User support forum of the Apache HTTP Server Project.<=
br>
See <URL:<a href=3D"http://httpd.apache.org/userslist.html" target=3D"_b=
lank">http://httpd.apache.org/userslist.html</a>> for more info.<br>
To unsubscribe, e-mail: <a href=3D"mailto:users-unsubscribe [at] httpd.apache.or=
g">users-unsubscribe [at] httpd.apache.org</a><br>
=A0 " =A0 from the digest: <a href=3D"mailto:users-digest-unsubscribe=
[at] httpd.apache.org">users-digest-unsubscribe [at] httpd.apache.org</a><br>
For additional commands, e-mail: <a href=3D"mailto:users-help [at] httpd.apache.=
org">users-help [at] httpd.apache.org</a><br>
<br>
</blockquote></div><br>
--0016367b6d5e5cbb6f048143a924--
Re: Avoid endless loop of mod_rewrite
On 8 March 2010 05:17, Michael Menegakis <arxeio [at] gmail.com> wrote:
> Hi all
>
> A rule is in place that that rewrites domains to www.domains
>
> In one particular home dir, I need the opposite,
>
> RewriteEngine On
> RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
> RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
>
> But it goes into an endless loop that eventually makes firefox spit
>
> 'The page isn't redirecting properly
> Firefox has detected that the server is redirecting the request for
> this address in a way that will never complete.'
>
> How to ignore the higher level rule?
Can you not add an extra RewriteCond to each rule to check if you are
or aren't in the 'one particular home dir' or not? For example:-
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteCond %{REQUEST_URI} ^/homedir/.* <-- This
rule only applies if we're in /homedir/
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteCond %{REQUEST_URI} !^/homedir/.* <-- This
rule only applies if we're not in /homedir/, note the exclamation
mark.
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
-- Phil
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org
Re: Avoid endless loop of mod_rewrite
On Mon, Mar 8, 2010 at 7:51 AM, Igor Cicimov <icicimov [at] gmail.com> wrote:
> Try using the following to stop the endless loops:
>
> RewriteCond %{ENV:REDIRECT_STATUS} 200
> RewriteRule .* - [L]
It doesn't stop looping if it's put before the rule, after the rule or
even if it's both after and before the rule.
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org
Re: Avoid endless loop of mod_rewrite
--00c09f9c97e66e5ddf04814a5652
Content-Type: text/plain; charset=ISO-8859-1
On Mon, Mar 8, 2010 at 10:47 AM, Michael Menegakis <arxeio [at] gmail.com> wrote:
> Hi all
>
> A rule is in place that that rewrites domains to www.domains
>
> In one particular home dir, I need the opposite,
>
> RewriteEngine On
> RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
> RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
>
> But it goes into an endless loop that eventually makes firefox spit
>
> 'The page isn't redirecting properly
> Firefox has detected that the server is redirecting the request for
> this address in a way that will never complete.'
>
> How to ignore the higher level rule?
>
> ------------------------------------------------------------ ---------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
> " from the digest: users-digest-unsubscribe [at] httpd.apache.org
> For additional commands, e-mail: users-help [at] httpd.apache.org
>
>
RewriteRules have never been a success for me in redirecting domain to
www.domain
I use this config inside a virtualhost for domain.
I.e. I have a virtualhost whose ServerName is set to domain.com
and only one line inside that -
RedirectPermanent / http://www.domain.com/
If you have SSL on your domain, this going to create some problems.
--
Nilesh Govindarajan
Site & Server Administrator
www.itech7.com
--00c09f9c97e66e5ddf04814a5652
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div class=3D"gmail_quote">On Mon, Mar 8, 2010 at 10:47 AM, Michael Menegak=
is <span dir=3D"ltr"><<a href=3D"mailto:arxeio [at] gmail.com">arxeio [at] gmail.c=
om</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"marg=
in: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-l=
eft: 1ex;">
Hi all<br>
<br>
A rule is in place that that rewrites domains to www.domains<br>
<br>
In one particular home dir, I need the opposite,<br>
<br>
RewriteEngine On<br>
RewriteCond %{HTTP_HOST} ^<a href=3D"http://www.domain.com" target=3D"_blan=
k">www.domain.com</a>$ [NC]<br>
RewriteRule ^(.*)$ <a href=3D"http://domain.com/$1" target=3D"_blank">http:=
//domain.com/$1</a> [R=3D301,L]<br>
<br>
But it goes into an endless loop that eventually makes firefox spit<br>
<br>
'The page isn't redirecting properly<br>
Firefox has detected that the server is redirecting the request for<br>
this address in a way that will never complete.'<br>
<br>
How to ignore the higher level rule?<br>
<div><div></div><div class=3D"h5"><br>
------------------------------------------------------------ ---------<br>
The official User-To-User support forum of the Apache HTTP Server Project.<=
br>
See <URL:<a href=3D"http://httpd.apache.org/userslist.html" target=3D"_b=
lank">http://httpd.apache.org/userslist.html</a>> for more info.<br>
To unsubscribe, e-mail: <a href=3D"mailto:users-unsubscribe [at] httpd.apache.or=
g">users-unsubscribe [at] httpd.apache.org</a><br>
=A0 " =A0 from the digest: <a href=3D"mailto:users-digest-unsubscribe=
[at] httpd.apache.org">users-digest-unsubscribe [at] httpd.apache.org</a><br>
For additional commands, e-mail: <a href=3D"mailto:users-help [at] httpd.apache.=
org">users-help [at] httpd.apache.org</a><br>
<br>
</div></div></blockquote></div><br>RewriteRules have never been a success f=
or me in redirecting domain to www.domain<br><br>I use this config inside a=
virtualhost for domain.<br><br>I.e. I have a virtualhost whose ServerName =
is set to <a href=3D"http://domain.com">domain.com</a><br>
<br>and only one line inside that - <br><br>RedirectPermanent / <a href=3D"=
http://www.domain.com/">http://www.domain.com/</a><br><br>If you have SSL o=
n your domain, this going to create some problems.<br clear=3D"all"><br>-- =
<br>
Nilesh Govindarajan<br>Site & Server Administrator<br><a href=3D"http:/=
/www.itech7.com">www.itech7.com</a><br><br>
--00c09f9c97e66e5ddf04814a5652--
Re: Avoid endless loop of mod_rewrite
On Tue, Mar 9, 2010 at 11:01 AM, Philip Wigg <phil [at] philipwigg.co.uk> wrote:
> On 9 March 2010 07:57, Michael Menegakis <arxeio [at] gmail.com> wrote:
>> On Mon, Mar 8, 2010 at 11:12 AM, Philip Wigg <phil [at] philipwigg.co.uk> wro=
te:
>>> On 8 March 2010 05:17, Michael Menegakis <arxeio [at] gmail.com> wrote:
>>>> Hi all
>>>>
>>>> A rule is in place that that rewrites domains to www.domains
>>>>
>>>> In one particular home dir, I need the opposite,
>>>>
>>>> RewriteEngine On
>>>> RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
>>>> RewriteRule ^(.*)$ http://domain.com/$1 [R=3D301,L]
>>>>
>>>> But it goes into an endless loop that eventually makes firefox spit
>>>>
>>>> 'The page isn't redirecting properly
>>>> Firefox has detected that the server is redirecting the request for
>>>> this address in a way that will never complete.'
>>>>
>>>> How to ignore the higher level rule?
>>>
>>> Can you not add an extra RewriteCond to each rule to check if you are
>>> or aren't in the 'one particular home dir' or not? For example:-
>>>
>>> RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
>>> RewriteCond %{REQUEST_URI} ^/homedir/.* =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <-- This
>>> rule only applies if we're in /homedir/
>>> RewriteRule ^(.*)$ http://domain.com/$1 [R=3D301,L]
>>>
>>> RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
>>> RewriteCond %{REQUEST_URI} !^/homedir/.* =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <-- This
>>> rule only applies if we're not in /homedir/, note the exclamation
>>> mark.
>>> RewriteRule ^(.*)$ http://www.domain.com/$1 [R=3D301,L]
>>
>> I do not have access to the httpd. However, the corporation I'm
>> dealing with doesn't seem to mind with rewriting urls per se, it's
>> just that it happens this particular hickup is a sideeffect of their
>> rules and they have no policy of changing httpd conf just for one of
>> their thousand domains just for one particular account (unless they
>> buy a server).
>>
>> So, I was wondering if there's a way .htaccess-side only to just not
>> go into an infinite loop.
>
> What was wrong with my suggestion of adding an extra RewriteCond?
It goes into an infinite loop again. I believe the root is forcing a
rule by 'inherit'.
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org
Re: Avoid endless loop of mod_rewrite
> It goes into an infinite loop again. I believe the root is forcing a
> rule by 'inherit'.
If I understand you correctly, you don't have access to the main httpd
configuration file. If there's a rewrite in that file which is
redirecting your site from domain.com to www.domain.com then I can't
think of anything you could do to stop it I'm afraid except asking
them not to apply that rule in your case. As you've seen, configuring
a rule to do the same in reverse will merely result in rewrite loops.
-- Phil.
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org
Re: Avoid endless loop of mod_rewrite
On 9 March 2010 07:57, Michael Menegakis <arxeio [at] gmail.com> wrote:
> On Mon, Mar 8, 2010 at 11:12 AM, Philip Wigg <phil [at] philipwigg.co.uk> wrot=
e:
>> On 8 March 2010 05:17, Michael Menegakis <arxeio [at] gmail.com> wrote:
>>> Hi all
>>>
>>> A rule is in place that that rewrites domains to www.domains
>>>
>>> In one particular home dir, I need the opposite,
>>>
>>> RewriteEngine On
>>> RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
>>> RewriteRule ^(.*)$ http://domain.com/$1 [R=3D301,L]
>>>
>>> But it goes into an endless loop that eventually makes firefox spit
>>>
>>> 'The page isn't redirecting properly
>>> Firefox has detected that the server is redirecting the request for
>>> this address in a way that will never complete.'
>>>
>>> How to ignore the higher level rule?
>>
>> Can you not add an extra RewriteCond to each rule to check if you are
>> or aren't in the 'one particular home dir' or not? For example:-
>>
>> RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
>> RewriteCond %{REQUEST_URI} ^/homedir/.* =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 <-- This
>> rule only applies if we're in /homedir/
>> RewriteRule ^(.*)$ http://domain.com/$1 [R=3D301,L]
>>
>> RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
>> RewriteCond %{REQUEST_URI} !^/homedir/.* =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 <-- This
>> rule only applies if we're not in /homedir/, note the exclamation
>> mark.
>> RewriteRule ^(.*)$ http://www.domain.com/$1 [R=3D301,L]
>
> I do not have access to the httpd. However, the corporation I'm
> dealing with doesn't seem to mind with rewriting urls per se, it's
> just that it happens this particular hickup is a sideeffect of their
> rules and they have no policy of changing httpd conf just for one of
> their thousand domains just for one particular account (unless they
> buy a server).
>
> So, I was wondering if there's a way .htaccess-side only to just not
> go into an infinite loop.
What was wrong with my suggestion of adding an extra RewriteCond?
Remember if you're configuring rewrites in an .htaccess, you'll
probably need to use RewriteBase:-
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewrit ebase
-- Phil.
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org
Re: Avoid endless loop of mod_rewrite
On Mon, Mar 8, 2010 at 11:12 AM, Philip Wigg <phil [at] philipwigg.co.uk> wrote:
> On 8 March 2010 05:17, Michael Menegakis <arxeio [at] gmail.com> wrote:
>> Hi all
>>
>> A rule is in place that that rewrites domains to www.domains
>>
>> In one particular home dir, I need the opposite,
>>
>> RewriteEngine On
>> RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
>> RewriteRule ^(.*)$ http://domain.com/$1 [R=3D301,L]
>>
>> But it goes into an endless loop that eventually makes firefox spit
>>
>> 'The page isn't redirecting properly
>> Firefox has detected that the server is redirecting the request for
>> this address in a way that will never complete.'
>>
>> How to ignore the higher level rule?
>
> Can you not add an extra RewriteCond to each rule to check if you are
> or aren't in the 'one particular home dir' or not? For example:-
>
> RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
> RewriteCond %{REQUEST_URI} ^/homedir/.* =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <-- This
> rule only applies if we're in /homedir/
> RewriteRule ^(.*)$ http://domain.com/$1 [R=3D301,L]
>
> RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
> RewriteCond %{REQUEST_URI} !^/homedir/.* =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <-- This
> rule only applies if we're not in /homedir/, note the exclamation
> mark.
> RewriteRule ^(.*)$ http://www.domain.com/$1 [R=3D301,L]
I do not have access to the httpd. However, the corporation I'm
dealing with doesn't seem to mind with rewriting urls per se, it's
just that it happens this particular hickup is a sideeffect of their
rules and they have no policy of changing httpd conf just for one of
their thousand domains just for one particular account (unless they
buy a server).
So, I was wondering if there's a way .htaccess-side only to just not
go into an infinite loop.
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org