blueman378 Posted February 11, 2009 Share Posted February 11, 2009 hi guys, i was wondering how would i go about (basically i have a rewrite rule which turns kidblog/disclaimer into kidblog/index.php?section=disclaimer so if someone types in kidblog/DisClaimEr it would translate that into kidblog/index.php?section=DisClaimEr, so how owuld i make it so even with capitals it still translates it into lowercase, i dont want a redirect or anything like that. Quote Link to comment Share on other sites More sharing options...
gevans Posted February 11, 2009 Share Posted February 11, 2009 In your htaccess file; Options +FollowSymLinks RewriteEngine on RewriteRule ^kidblog/([A-Za-z])$ kidblog/index.php?section=$1 Quote Link to comment Share on other sites More sharing options...
killah Posted February 11, 2009 Share Posted February 11, 2009 All i can think of is strotolower() how ever i do not know how to turn that into linux command. Quote Link to comment Share on other sites More sharing options...
printf Posted February 11, 2009 Share Posted February 11, 2009 Just ad * NC * to the condition... kidblog/index.php?section=$1 [L,NC] Quote Link to comment Share on other sites More sharing options...
gevans Posted February 11, 2009 Share Posted February 11, 2009 Just ad * NC * to the condition... kidblog/index.php?section=$1 [L,NC] With A-Za-z as the regex surely the [NC] part is unneseccary? Quote Link to comment Share on other sites More sharing options...
haku Posted February 11, 2009 Share Posted February 11, 2009 I think the problem is when he gets that variable using $_GET. Which means that this should work: $var = strtolower($_GET['section']); Quote Link to comment Share on other sites More sharing options...
printf Posted February 11, 2009 Share Posted February 11, 2009 Just ad * NC * to the condition... kidblog/index.php?section=$1 [L,NC] With A-Za-z as the regex surely the [NC] part is unneseccary? Ya, but using a regex makes the point of the rewrite kind of silly, if you're only wanting to rewrite KiDlOg/DisClaimEr, then NC is the best way because what stops someone from doing KiDlOg/monkeys, you lose the restriction on the rewite because your allowing for anything after * / *. Plus it still wont match because kidlog is not in lower case! Quote Link to comment Share on other sites More sharing options...
gevans Posted February 11, 2009 Share Posted February 11, 2009 Ya, but using a regex makes the point of the rewrite kind of silly, if you're only wanting to rewrite KiDlOg/DisClaimEr, then NC is the best way because what stops someone from doing KiDlOg/monkeys, you lose the restriction on the rewite because your allowing for anything after * / *. Plus it still wont match because kidlog is not in lower case! I see what you're saying, but when I use rewrite on sites it's usually for everypage (maybe not in this case) so I use a regular expression that will allow letters and dashes or whatever's needed. Then the $_GET value is checked in the script as it should be. If it's wrong they go to the home page so people misspelling etc don't get an error but a redirect to the home page of the site. Quote Link to comment Share on other sites More sharing options...
blueman378 Posted February 11, 2009 Author Share Posted February 11, 2009 cheers guys, i use the regex because i only want letters there, the ht access file is in the kidblog directory so the redirecting wont work anywhere else anyway, and i know im able to do it through php, i was jsut wondering is there anyway to do it jsut through htaccess? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.