Jump to content

Recommended Posts

How would I got about using mod_rewrite to rewrite:

 

www.domain.com/index.php?home to www.domain.com/home

 

but also have

 

www.domain.com/index.php?profile=user_name to www.domain.com/username

 

I guess I should be clear about this part:

 

www.domain.com/index.php?profile=user_name to www.domain.com/username

 

That should be a variable $user_name, would be rewritten to the same value of the variable.

 

So:

 

www.domain.com/index.php?profile=John would be rewritten to www.domain.com/John

 

Could I just order them in order of importance, like this:

 

RewriteRule ^/?([a-zA-Z0-9-]+)(?:/(.*))?$ index.php?$1
RewriteRule ^/?([a-zA-Z0-9-]+)(?:/(.*))?$ index.php?profile=$1

 

So things like /home would be caught first and see that value is in the php file. And when something isn't caught it would go to the next rewrite rule. I guess one issue is I have an else statement in the php file, so it will also return that, as opposed to going to the rewrite rule.

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.