homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

What's wrong with this rewrite rule
It has no problem on my dev computer

10+ Year Member

Msg#: 3354416 posted 11:03 am on May 31, 2007 (gmt 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?



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

Msg#: 3354416 posted 12:28 am on Jun 1, 2007 (gmt 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.


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved