Forum Moderators: phranque

Message Too Old, No Replies

htaccess prob with lowercase L's

weird case where htaccess ignores lowercase L's

         

auxiv

8:13 am on Aug 18, 2009 (gmt 0)

10+ Year Member



This is weird!

My code:


RewriteEngine on
RewriteCond %{REQUEST_URI} ^(^/usr/)(.*)$
RewriteRule ^([^link].*)$ http://www.xyz.com/usr/?link=%2 [R,QSA,L]

and my index.php file is as follows:


isset($_GET['link'])? $usrnm = $_GET['link'] : $usrnm = '';
if ($usrnm != ''){
redirect to user profile
}
else {
redirect to home page
}

(I realize my query is missing from above php which I believe to be irrelevant, my query works fine)

everything works when i use "/usr/auxiv" or any other user in our database EXCEPT users starting with l's such as lilly or linda or lonny or larry (etc) However, It DOES work
if i were to use Capital Letters Such as "/usr/Lilly" or "/usr/Linda" or "/usr/Lonny" These all work!

I have users that start with lowercase L's that need to access: /usr/larry (lowercase L).

I find this strange because it only seems to effect L's, all the other user names can use lowercase such as /usr/happy_gilmore

when a lower case L username is requested as such: "/usr/larry" it bypasses my htaccess file and looks in the "usr" directory for a folder named "larry" where it should be redirected to my php file for handling and redirect.

when an uppercase L is used such as: "/usr/Larry" the htaccess decides it wants to redirect to the php file
and then will handle correctly.

/usr/larry = 404
/usr/auxiv = ok
/usr/Larry = ok
/usr/dilbert = ok

I believe the problem to be within the htaccess because if the user doesnt exist the php is set to redirect to the home page (names not in the database). Where with lowercase L's it doesnt even redirect, instead it 404's (looking for the folder in the "usr" dir.

Thanks for any help!

Caterham

9:57 am on Aug 18, 2009 (gmt 0)

10+ Year Member



when a lower case L username is requested as such: "/usr/larry" it bypasses my htaccess file

Well, you told the regex engine with

^([^link].*)$
that the first character must not be a
k n i
or
l
...

auxiv

10:16 am on Aug 18, 2009 (gmt 0)

10+ Year Member




Well, you told the regex engine with ^([^link].*)$ that the first character must not be a k n i or l

wow I misunderstood! Thank you Caterham, I have it settled :)

& much appreciation webmasterworld for your help.

jdMorgan

1:01 pm on Aug 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The code is also a bit redundant, as just

RewriteEngine on
RewriteRule ^(.+)$ /usr/?link=$1 [QSA,L]

should be entirely sufficient (and functionally equivalent), assuming that this code goes into the /usr/.htaccess file.

Note however that the syntax has been changed from that of an external redirect to that of an internal rewrite, so that the rewritten internal script path and query string *is not* exposed to the client (or to search engines).

Jim