Forum Moderators: phranque

Message Too Old, No Replies

Rewrite Question

         

stargoonman

11:55 am on Jul 16, 2009 (gmt 0)

10+ Year Member



I'm trying to rewrite URL with Rewrite module with .htaccess, but it throws 500 Internal Server Error.

==================================================================
CODE:

RewriteRule ^([^/]+)\.([^/]+)$ ./name_checker.php?f=$1&l=$2 [L]
==================================================================

So if I type 'http://localhost/firstname.lastname' in the address bar,

the variables should be
$f = firstname
$l = lastname

I must use 'dot' between them.

Anyone fixes it will be highly appreciated. I've been dying in 3 days with this.
Please.

Thank you in advance

jdMorgan

3:13 pm on Jul 16, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



From the syntax of the rule, I infer that this code is installed in .htaccess.

If that is the case, then the rule will rewrite name-checker.php to itself recursively. In other words, you've got an infinite loop. You can confirm this by looking at your server error log file.

The fix is simple: Explicitly prevent requests for name-checker.php from being rewritten:


RewriteCond %{REQUEST_URI} !^/name_checker\.php$
RewriteRule ^([^/]+)\.([^/]+)$ name_checker.php?f=$1&l=$2 [L]

Jim