Welcome to WebmasterWorld Guest from 3.227.240.31

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

ModRewrite causing Error 500

     
5:05 am on Dec 5, 2010 (gmt 0)

Junior Member

10+ Year Member

joined:May 12, 2007
posts: 91
votes: 0


So...let me start by specifying that I am using 1and1 shared Linux hosting for this project. Unfortunately i am stuck with this...so working within their system is a must. Sadly they do not provide any way to find out what the server logs say the real problem is behind my error 500 i get with the below modRewrite (lots of other stuff in my .htaccess file too...but this part is the problem and is the current only thing pertaining to rewrite rules).

With no problems, I can go to www.demo.com/view.php

If i add the following line to my .htaccess file, I can go to www.demo.com/testpath/ with no problems:
RewriteRule ^testpath/$ /view.php [NC,L]

If i remove the line above and replace it with the following (which i expect would identify the same string (plus others) and try to visit www.demo.com/testpath/ i get Server Error 500:
RewriteRule ^([a-z0-9\-/]+)$ /view.php [NC,L]

What am i doing wrong?
This is actually a MUCH larger regex/set of rewrites, but i have stripped it down this far and am still erroring out...so let's start here and see what happens... HELP!
7:50 am on Dec 5, 2010 (gmt 0)

Preferred Member

10+ Year Member

joined:July 25, 2006
posts: 460
votes: 0


I believe the hypen in the character class will always be interpreted as a range operator unless it is first or last, so try these instead. The hyphen doesn't need to be escaped with \ in this situation:

[-a-z0-9/]
[a-z0-9/-]

The reason for the 500 error might have been that \-/ was being interpreted as the range between \ and /, but \ is higher in ASCII order than /, so the range is backwards and therefore not valid.
10:57 pm on Dec 5, 2010 (gmt 0)

Junior Member

10+ Year Member

joined:May 12, 2007
posts: 91
votes: 0


BRILLIANT! Thank you VERY much! This has completely fixed everything...