Joseph Robidoux
Joseph Robidoux

Reputation: 351

Beginner's apache mod_rewrite assistance with .htaccess configuration

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

Upvotes: 0

Views: 82

Answers (2)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798576

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

Upvotes: 1

Gumbo
Gumbo

Reputation: 655219

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

Upvotes: 1

Related Questions