Portal Home > Knowledgebase > Articles Database > mod_rewrite problems
mod_rewrite problems
Posted by Jamza, 01-11-2010, 07:31 PM |
I have a simple htaccess file (below) that should rewrite the URL from something like page http://127.0.0.1/urlhandler.php?page=test to http://127.0.0.1/test/.
But everytime I try to access something it gives me a 500 internal server error.
I looked in the server log and it outputs this entry:
I can't see what the error really is, does anybody know how I can fix this error?
|
Posted by foobic, 01-11-2010, 07:39 PM |
Your rewritten url still matches the rewrite rule, so it gets rewritten again, and again, etc. until you hit the redirect limit.
Add a RewriteCond before your rule that excludes urlhandler.php.
|
Posted by Jamza, 01-11-2010, 08:24 PM |
Thanks, that had fixed it.
Never realised that it would include the url handler.
|
Posted by Jamza, 01-12-2010, 10:30 AM |
Ive run into another problem.
Yes thanks to foobic I did get HTaccess to push the url to my url handling script. But the problem is, its only pushing one thing. http://127.0.0.1/foo would work, but http://127.0.0.1/foo/bar/ wouldn't (gives a 404).
This is my htaccess file at the moment:
Does anyone know how I can change this to send the whole string after the domain (http://127.0.0.1/foo/bar/) to my script? Thank you.
|
Posted by mattle, 01-12-2010, 11:51 AM |
Your regular expression dictates that the string must match the character set "not forward slash" from beginning to end. The string "foo/bar/" has forward slashes and therefore does not meet your condition. If you want to send everything after http://127.0.0.1/ (rewrite rules start matching after the domain's trailing slash) then this regex should be all you need: ^(.*)$
|
Posted by Jamza, 01-12-2010, 03:35 PM |
Thats solved it. Now its working completely as I want it. Thank you so much
|
Add to Favourites Print this Article
Also Read