mod_rewrite and the "infinite loop"

This is a discussion on mod_rewrite and the "infinite loop" within the Apache Web Server forums, part of the Web Server and Related Forums category; Hello, I'm new to mod_rewrite so please bear with me... I've created a simple rule as follows: RewriteRule ^...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-20-2007
Toine
 
Posts: n/a
Default mod_rewrite and the "infinite loop"

Hello,

I'm new to mod_rewrite so please bear with me...

I've created a simple rule as follows:

RewriteRule ^store/([0-9]{3,})$ /store/?itemid=$1 [L]

This rule does the job. However, I'm concerned that customers have
bookmarks to the old query string URL (eg: store/?itemid=200). I'd
like my users to use the new URL (eg: store/200) instead.

So I tried setting up a PHP redirect that forwards store/?itemid=200
to store/200, but this creates an infinite loop.

Is there anyway I can redirect old query string URLs to the new URL,
without creating an infinite loop?

Thanks,
Toine

  #2 (permalink)  
Old 02-22-2007
shimmyshack
 
Posts: n/a
Default Re: mod_rewrite and the "infinite loop"

On 20 Feb, 04:22, "Toine" <bapo...@gmail.com> wrote:
> Hello,
>
> I'm new to mod_rewrite so please bear with me...
>
> I've created a simple rule as follows:
>
> RewriteRule ^store/([0-9]{3,})$ /store/?itemid=$1 [L]
>
> This rule does the job. However, I'm concerned that customers have
> bookmarks to the old query string URL (eg: store/?itemid=200). I'd
> like my users to use the new URL (eg: store/200) instead.
>
> So I tried setting up a PHP redirect that forwards store/?itemid=200
> to store/200, but this creates an infinite loop.
>
> Is there anyway I can redirect old query string URLs to the new URL,
> without creating an infinite loop?
>
> Thanks,
> Toine


do you mean that you wish all users to see the new url even if they
put in the old one:

RewriteEngine On
ReWriteCond %{QUERY_STRING} itemid=([0-9]{3,})
ReWriteCond %{QUERY_STRING} !stop=yes
ReWriteRule . /store/%1/? [R=301]
ReWriteRule ^store/([0-9]{3,})/?$ /store/index.php?itemid=$1&stop=yes
[L]

muddled and if David is right, unnecessary, I'm just not quite
intelligent enough to see David's point, although he could well be
right.

  #3 (permalink)  
Old 02-25-2007
Toine
 
Posts: n/a
Default Re: mod_rewrite and the "infinite loop"

On Feb 22, 1:28 pm, "shimmyshack" <matt.fa...@gmail.com> wrote:
> On 20 Feb, 04:22, "Toine" <bapo...@gmail.com> wrote:
>
>
>
> > Hello,

>
> > I'm new to mod_rewrite so please bear with me...

>
> > I've created a simple rule as follows:

>
> > RewriteRule ^store/([0-9]{3,})$ /store/?itemid=$1 [L]

>
> > This rule does the job. However, I'm concerned that customers have
> > bookmarks to the old query string URL (eg: store/?itemid=200). I'd
> > like my users to use the new URL (eg: store/200) instead.

>
> > So I tried setting up a PHP redirect that forwards store/?itemid=200
> > to store/200, but this creates aninfiniteloop.

>
> > Is there anyway I can redirect old query string URLs to the new URL,
> > without creating aninfiniteloop?

>
> > Thanks,
> > Toine

>
> do you mean that you wish all users to see the new url even if they
> put in the old one:
>
> RewriteEngine On
> ReWriteCond %{QUERY_STRING} itemid=([0-9]{3,})
> ReWriteCond %{QUERY_STRING} !stop=yes
> ReWriteRule . /store/%1/? [R=301]
> ReWriteRule ^store/([0-9]{3,})/?$ /store/index.php?itemid=$1&stop=yes
> [L]
>
> muddled and if David is right, unnecessary, I'm just not quite
> intelligent enough to see David's point, although he could well be
> right.


This solution works good. I never thought about using a "stop"
variable. Thanks for your assistance.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:01 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0