lore_lanu Posted July 4, 2010 Share Posted July 4, 2010 I wasn't sure which forum to ask this in, so hopefully its okay to post it here... I'm having trouble with a simple .htaccess RewriteRule (below) Options +FollowSymlinks RewriteEngine on RewriteRule ^account/([^/]+)$ account.php?mod=$1 [NC] On account.php I check to see if $_GET['mod'] is set, and try to print out its contents, but it never seems to be set... even with a url like www.mysite.com/account/text (which is what I am going for) Could anyone tell me what I am doing wrong here? Any help is appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/206677-htaccess-question/ Share on other sites More sharing options...
lore_lanu Posted July 8, 2010 Author Share Posted July 8, 2010 As an update, after messing around with the code, I still can't get it to work, which is odd considering I've done more complicated stuff on other directories on the same site. The code below works like it is supposed to: Options +FollowSymlinks RewriteEngine on RewriteRule ^(.+)/(.+)$ /users/account.php?mod=$2 [NC] But when I change it to this, it doesn't work.. .which makes absolutely no sense to me. Options +FollowSymlinks RewriteEngine on RewriteRule ^account/(.+)$ /users/account.php?mod=$1 [NC] I'm stumped as to why this is not working. Once again, any help is appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/206677-htaccess-question/#findComment-1083303 Share on other sites More sharing options...
cags Posted July 9, 2010 Share Posted July 9, 2010 The most likely reason would seem to be that the REQUEST_URI does not begin with 'account/'. Is the .htaccess file located in the root folder? If it isn't and is instead located in a sub-folder then the URL you are matching against will not be a full URL. What I mean by this is if your .htaccess file is in a folder called account. Then the pattern would simply need to be. Options +FollowSymlinks RewriteEngine on RewriteRule ^(.+)$ /users/account.php?mod=$1 [NC] Quote Link to comment https://forums.phpfreaks.com/topic/206677-htaccess-question/#findComment-1083494 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.