Welcome to WebmasterWorld Guest from

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)

Full Member

10+ Year Member

joined:Jan 19, 2003
votes: 0

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 June 1, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
votes: 0

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.



Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members