0

Current situation

RewriteRule ^$ /index.php?page=Portal [R=301,L]

When a user comes to the website and goes to the "root" url of the domain (RegExp "^$") he's redirected to /index.php?page=Portal

That's working.

Now we have "index.php?page=Portal" in the google index and we have tons of links to that page on various locations all over the internet.

Intended new situation

We want the portal page to show up on the root url - no redirect. That's no problem... Just remove the redirect:

RewriteRule ^$ /index.php?page=Portal [L]

Now we also want the old url to redirect to the new location, and that's where I fail but can't see why:

RewriteCond %{QUERY_STRING} ^page=Portal$
RewriteRule ^index.php$ http://www.jacatu.de/? [R=301,L]

As soon as I do this I end up in a redirect loop:

alt text

(When I change to 302 in .htaccess I see 302 redirects, so the loop really seems to be caused by mod_rewrite)

But why? All rules are marked as last [L] - so I think I can rule out that rule 2 triggers rule 1.

1
  • 1
    You may want to enable mod_rewrite logging (RewriteLogLevel 2 + RewriteLog /path/to/logfile) before assuming anything. I had several mod_rewrite problems that were solved just by reading the mod_rewrite logs. Commented Dec 14, 2010 at 11:19

1 Answer 1

0

I enabled logging as suggested by Jacek Prucia and in fact it looked like having [L] in the URL doesn't stop execution. Both rules were processed.

I now changed the first rewrite to

RewriteRule ^$ /index.php?page=Portal&int=1 [L]

so that it doesn't match the RewriteCond of the internal rewrite so theoretically my problem is solved. It would be nice to know, though, why it did what it did. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.