Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/206677-htaccess-question/
Share on other sites

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!

Link to comment
https://forums.phpfreaks.com/topic/206677-htaccess-question/#findComment-1083303
Share on other sites

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]

Link to comment
https://forums.phpfreaks.com/topic/206677-htaccess-question/#findComment-1083494
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.