Vinaya Maheshwari
Vinaya Maheshwari

Reputation: 575

htaccess rule to redirect url from url parameter to query string

I want to convert last / to ? for a url.

For eg. : /custom/2342546578 to custom?2342546578 using htaccess rule.

where custom is my page and last string is the unique id for customer identification.

How to use htaccess rule for redirection?

Upvotes: 1

Views: 39

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

You can use the following RewriteRule in your root/.htaccess

RewriteRule ^custom/([A-Za-z0-9]+)/?$ /custom?$1 [L]

This will rewrite your url from /custom/123 to /custom?123 .

Upvotes: 1

Related Questions