I'm trying clean helpful Web addresses using mod_rewrite. I am certain this can be a common query but I'm not so hot with mod_rewrite:

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

I wish to have the ability to rewrite it such as this:

http://mysite.com/user/user/fatcatmat/sort/popularv (It is possible to method to remove replicates inside a URL?)

I believe I've handled to complete removing the PHP extension.

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

May be the above correct?

For that separate pages, I'd have something similar to this.

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

Primary Question: Its a little tiresome to complete all of the above but it is possible to MEGA rewrite rule which will just place "/" among variables as well as their values and take away the .php extension all pages?

Appreciate any help.

Use smth such as this:

RewriteBase /
RewriteCond %{QUERY_STRING} ^(\w+)=(\w+)&(\w+)=(\w+)$ [NC]
RewriteRule ^user.php$ user/%1/%2/%3/%4? [NC,R=301,L]

RewriteRule ^user/(\w+)/(\w+)/(\w+)/(\w+)$ user.php?$1=$2&$3=$4 [L]

Try these rules:

RewriteCond %{THE_REQUEST} ^[A-Z]+\ (/[^/?\s]+)+\.php[?/\s]
RewriteCond %{QUERY_STRING} ^([^/&=]+)=([^/&]+)(&([^&].*))?$
RewriteRule \.php$ ?%4 [N,E=PATH:%{ENV:PATH}/%1/%2]
RewriteCond %{ENV:PATH} ^/
RewriteRule \.php$ %{ENV:PATH} [L,R=301]

RewriteRule ^(.*)/([^/]+)/([^/]+)$ $1?$2=$3 [N,QSA]
RewriteRule ^([^/]+)/([^/]+)$ $1.php?$1=$2 [L,QSA]

But it might be a great deal simpler to achieve that with PHP: Check what URI path continues to be asked for (see $_SERVER['REQUEST_URI']) and redirect if required (see [cde] function).

You may create rewrite rules out of this website quickly Mod_rewrite generator