Reputation: 2327
I followed desiquintans tutorial how to clean up the url. In my case www.mySite.com/detail.php?id=324 and it works great except that it's affecting other pages.
This is how my .htaccess file looks like:
RewriteBase /
RewriteEngine on
Options All -Indexes
DirectoryIndex index.php index.html index.htm
RewriteRule ^([0-9]+)$ detail.php?id=$1
RewriteRule ^([0-9]+)/$ detail.php?id=$1
That last line makes Chrome warn me about redirect cycles on some pages that has different path. Shouldn't it just affect pages with 'detail.php?id=' extension?
Upvotes: 1
Views: 12135
Reputation: 19528
I suspect your problem is because of your options, give this a try.
Options +FollowSymLinks -MultiViews -Indexes
DirectoryIndex index.php index.html index.htm
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)/?$ /detail.php?id=$1 [L]
I am also cutting your rule into one /?
makes the last slash optional so it should work for both.
And the 2 conditions are there to prevent you from redirecting existent files and folders.
Keep in mind that your rule should affect only URI that start and ends with numbers with and without the ending slash like for example:
http://domain.com/1234/
http://domain.com/1234
http://domain.com/200
http://domain.com/420/
It will not affect any other URLs.
Upvotes: 6