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 ^...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
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. |
|
|||
|
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. |