Mod_Rewrite: Insert "/" between variables and values in URL

Posted by Abs on Stack Overflow See other posts from Stack Overflow or by Abs
Published on 2009-07-15T22:45:32Z Indexed on 2010/04/22 17:03 UTC
Read the original article Hit count: 224

Filed under:
|
|

Hello all,

I am attempting clean useful URLs using mod_rewrite. I am sure this is a common question but I am not so hot with mod_rewrite:

I have this URL: http://mysite.com/user.php?user=fatcatmat&sort=popularv

I want to be able to rewrite it like this:

http://mysite.com/user/user/fatcatmat/sort/popularv (Is there a way to remove duplicates in a URL?)

I think I have managed to do the removal of the PHP extension.

RewriteRule ^(.*)\$ $1.php [nc]

Is the above correct?

For the separate pages, I would have something like this.

RewriteRule ^/?user(/)?$ user.php

Main Question: Its a bit tedious to do all the above but is there a MEGA rewrite rule that will just place "/" in between variables and their values and remove the .php extension from all pages?

Thank you for any help.

© Stack Overflow or respective owner

Related posts about mod-rewrite

Related posts about apache