Welcome to WebmasterWorld Guest from 54.159.246.164

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

What's wrong with this rewrite rule

It has no problem on my dev computer

   
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?

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

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 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