Reputation: 1389
I have the following in my .htaccess
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^task/(.*)/?$ index.php?mode=task&id=$1 [L]
RewriteRule ^(.*)/?$ index.php?mode=$1 [L]
If the last line is included, no matter what is put in the URL it sets $_GET['mode'] to index.php. Without the last line included, or if I set it to go to index.php?mode=home, for instance, it works fine, but there isn't a catchall.
I don't see what the problem is, but it's probably something simple. If someone else could take a moment to steer me right, that'd b great. Thanks!
Upvotes: 0
Views: 128
Reputation: 143906
When you apply that to ,say, /task/123
, this is what happens, (assuming that URI doesn't exist):
^task/(.*)/?$
so the URI gets rewritten to index.php?mode=task&id=123
index.php?mode=task&id=123
^task/(.*)/?$
, do nothing^(.*)/?$
, so the URI gets rewritten to index.php?mode=index.php
What you need to do is add a condition to the 2nd rule:
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^(.*)/?$ index.php?mode=$1 [L]
Upvotes: 1