.htaccess - regex syntax is correct but still internal error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • n8kindt
    New Member
    • Mar 2008
    • 221

    .htaccess - regex syntax is correct but still internal error

    i'm trying to allow my website to use a http://ourdomain.com/fname.lname/ format. i am fairly certain my regex syntax is correct. here's what i have:


    Code:
    <IfModule mod_rewrite.c>
    	RewriteEngine on
            RewriteCond   %{REQUEST_URI}   \/.+\.?.+\/*$	[NC]
    	RewriteRule ^(.*)$ /index.php?path=$1 [L,QSA]
    </IfModule>
    the weird thing is i can get the above to work by replacing the rewrite with:
    RewriteCond %{REQUEST_URI} \/.?\.?.?\/*$ [NC]
    (replacing the two "+" with two "?")

    unfortunately, i have no interest in using the http://www.ourdomain.com/f.n/ format

    anybody have any clue why this is happening?
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    I tried this, and it worked on my server (Apache/2.2.8).

    I did see one problem tho. Your regex seemed to match any string rather then just your "firstname.last name" scenario.

    It should look a bit more like this:
    Code:
    RewriteCond %{REQUEST_URI} .+?\..+?/*$ [NC]
    RewriteRule ^(.+?)\.(.+?)/*$ index.php?first=$1&last=$2 [L,QSA]
    Note that I removed the / in front of the index.php in the Rule so I could test this in a sub-directory.

    By itself, this gives a 404 error if the URL isn't formatted like you showed above.

    This isn't perfect tho. Because you used the dot class the name can contain all sorts of weird characters. You may want to specify a more limited range of characters.

    Comment

    • n8kindt
      New Member
      • Mar 2008
      • 221

      #3
      Originally posted by Atli
      Hi.

      I tried this, and it worked on my server (Apache/2.2.8).

      I did see one problem tho. Your regex seemed to match any string rather then just your "firstname.last name" scenario.

      It should look a bit more like this:
      Code:
      RewriteCond %{REQUEST_URI} .+?\..+?/*$ [NC]
      RewriteRule ^(.+?)\.(.+?)/*$ index.php?first=$1&last=$2 [L,QSA]
      Note that I removed the / in front of the index.php in the Rule so I could test this in a sub-directory.

      By itself, this gives a 404 error if the URL isn't formatted like you showed above.

      This isn't perfect tho. Because you used the dot class the name can contain all sorts of weird characters. You may want to specify a more limited range of characters.
      wow, i really like how you improved on my idea and improved the syntax. i will test it out later tonite. thank you so much!!

      Comment

      • n8kindt
        New Member
        • Mar 2008
        • 221

        #4
        oh boy. after testing it for about a half hour with the same 500 error returning, i decided to try it on another domain i have access to that is hosted by a completely different company. wouldn't you know, it worked. so the syntax is obviously not the problem. it is so wierd that it trips on more than one ".+" in the regex.

        is there some kind of setting that might be tweaked on my site causing the error? i also found out that the site in question is running an ancient Apache/1.3.41. not the first time this host has been behind the times. might have to give up yet another project due to dark aged hosting sites...

        Comment

        • n8kindt
          New Member
          • Mar 2008
          • 221

          #5
          still struggling with this. suggestions anyone?

          Comment

          Working...