views:

20

answers:

2

Hi, noob when it comes to .htaccess.

I need a mod_rewrite of a URL. URL example is as shown:

http://example.com/folder/script.php?location=UK&Name=Fred

I want it to transform to:

http://example.com/folder/UK/Fred
+1  A: 

Try this rule:

RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ $1/script.php?location=$2&Name=$3

This will rewrite requests to /<folder>/<location>/<Name> internally to /<folder>/script.php?location=<location>&Name=<Name>.

Gumbo
+1  A: 
RewriteCond %{QUERY_STRING} location=([^&]+)&Name=(.+)
RewriteRule ^/folder/script.php$ http://website.com/folder/%1/%2? [R]
Ignacio Vazquez-Abrams