Reputation: 8990
i have this url that i wanted to make friendly, using rewrite on .htacess but it gives me an error(500 internal server error), this is my orginal php url
http://www.example.com/viewtopic.php?topic=lovetopic
i want to change it to this:
http://www.example.com/lovetopic
this is my whole htaccess code is this:
RewriteEngine On
RewriteRule ^user/([^/]*)$ /viewprofile.php?user=$1 [L]
RewriteRule ^([^/]*)$ /viewtopic.php?topic=$1 [L]
i dont know what the problem is
EDIT the server error log is giving me this error
[Thu Oct 14 20:34:36 2010] [error] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.,
Upvotes: 0
Views: 2417
Reputation: 655239
The pattern of your second rule ^([^/]*)$
does also match /viewtopic.php
without the path prefix /
, i.e. viewtopic.php
. That’s why you’re having an infinite recursion.
You can use the following condition to exclude that:
RewriteCond $1 !=viewtopic.php
RewriteRule ^([^/]*)$ /viewtopic.php?topic=$1 [L]
Or use this condition to exclude all existing files:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)$ /viewtopic.php?topic=$1 [L]
Or use this rule in front of you other rules to stop every request that can be mapped to an existing file being rewritten by any following rules:
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
Upvotes: 4