user5923290
user5923290

Reputation:

Redirect URLs with parameters

I have URLs like

www.mysite.com/city/some-url-structure 

I need to add parameters to the end of the URL like

www.mysite.com/city/some-url-structure?sort_value=distance

How do I make a rewrite rule in .htaccess file to get that?

Upvotes: 1

Views: 60

Answers (1)

anubhava
anubhava

Reputation: 786359

You can use this redirect rule:

RewriteEngine On

RewriteCond %{QUERY_STRING} !(^|&)sort_value=distance(&|$) [NC]
RewriteRule ^city/some-url-structure/?$ %{REQUEST_URI}?sort_value=distance [L,NC,QSA,NE,R=301]

Upvotes: 1

Related Questions