arjun
arjun

Reputation: 1203

Rewrite URL using htaccess : Convert url slug to url parameter

I want to redirect www.abc.com/pqr/xyz/ to www.abc.com/pqr/?param=xyz

I gave a try with the following :

RewriteRule "^pqr/(.+)/$" "%{DOCUMENT_ROOT}/pqr/?param=$1"  [L]

I suspect that above rewrite rule is making an infinite loop.

Please help to do the rewrite correctly.

Upvotes: 0

Views: 347

Answers (1)

nandal
nandal

Reputation: 2634

Use the following Rewrite Rules in .htaccess file:-

RewriteEngine on
RewriteRule "^pqr\/([^\/]+)\/?$"  "/pqr/?param1=$1" [L]

Upvotes: 1

Related Questions