Forum Moderators: phranque

Message Too Old, No Replies

What's wrong with this rewrite rule

It has no problem on my dev computer

         

iProgram

11:03 am on May 31, 2007 (gmt 0)

10+ Year Member



RewriteEngine on

...
other rewrite rule here which works
...
RewriteCond %{REQUEST_FILENAME}!-d
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^([a-zA-Z0-9-_\.\/]+)$ /test.php?id=$1 [L]

The last one will generate an 500 error to my server. I want to rewrite all requests with letters, number "_", "-" and "." to test.php?id=...
What's wrong with it and how to fix it?

jdMorgan

12:28 am on Jun 1, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Escape the hyphen. No need to escape the others. Use [NC] to eliminate "a-z" and speed things up.

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Z0-9./_\-]+)$ /test.php?id=$1 [NC,L]

The difference is likely in the POSIX regex library on each machine; It's part of the OS, not the server software.

Jim