I have what I thought was a simple mod_rewrite rule.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^store/([a-z0-9_\-]+)/?([a-z0-9_\-]+)?(.*)?$ store/$2?store_name=$1$3 [L]
However, when I go to a URL like:
http://www.mydomain.com/store/e95_airport/
It turns into:
http://www.mydomain.com/store/e95_airport/////////////////////
I’m expecting the URL to load:
index.php?store_name=e95_airport
It works fine when I call a URL like:
store/e95_airport/some-page-other-than-index.php
I’ve disabled all other mod_rewrite rules just in case there was a conflict somewhere else in my .htaccess file. Is there anyone here who can diagnose what’s wrong with my rewrite rule? Any help is greatly appreciated!
The problem is that the site is getting itself into a loop because you’re redirecting it to essentially the same address.
Okay, so you are changing it with the rewrite, but the URL it rewrites it to still matches the expression.
The way mod_rewrite works is that once it’s rewritten the URL, it then effectively requeries itself with the new URL. So if your new URL still matches the expression, it will get into a loop.
Why it stops at 21 slashes? This is because Apache will detect when it’s in a loop, and stop if it requeries itself twenty times.