Jump to content

Rewrite to different kinds of php conditions


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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.