0

I can't figure out a way to stop this htaccess redirect from looping.

Options +FollowSymLinks
Options -Multiviews
RewriteOptions MaxRedirects=1
RewriteEngine On 
RewriteRule ^pages/?$ page.php?p=g&id=1$1 [L,QSA]
RewriteCond %{QUERY_STRING}  ^p=g&id=1$ [NC]
RewriteRule ^page\.php$ /pages/? [r=301,nc]

Now it just loops until the browser says "This webpage has a redirect loop". The address bar on the browser shows the correct address at least..

Is it possible to stop it from looping?

I have tried: RewriteOptions MaxRedirects=1 with no success.

I would like to have it so any links to /page.php?p=g&id=1 redirect to /pages/

Thanks.

Eddie
  • 337
  • 3
  • 17

2 Answers2

0

You have 2 rules:

  1. A -> B
  2. B -> A

you've made the loop so it works as it should. You have to decide which way you want to go.

pawel7318
  • 3,383
  • 2
  • 28
  • 44
0

You can probably just omit the first rule you had:

RewriteEngine On 
RewriteCond %{QUERY_STRING}  ^p=g&id=1$ [NC]
RewriteRule ^page\.php$ /pages/? [R=301,L]
arco444
  • 22,002
  • 12
  • 63
  • 67
  • It's redirecting as I wanted it too with that method, but to a 404, "The requested URL xxx was not found on this server. Any suggestions? – Eddie Mar 22 '14 at 08:45