JoomlaSriLanka
JoomlaSriLanka

Reputation: 21

301 Redirect for URLs with % percentage mark on htacess

I neee to redirect

http://www.example.com.au/recipes/recipe.aspx?name=91-Sunflower%20Crackers

to https://www.example.com.au/recipes/

I followed so many posts but this is not redirecting at all.

This is my code

RewriteCond %{QUERY_STRING} ^name=91-Sunflower%20Crackers$
RewriteRule ^/recipes/recipe\.aspx?$ /recipes/? [NE,L,R]

What is the error here ?

Upvotes: 1

Views: 70

Answers (1)

anubhava
anubhava

Reputation: 786329

This rule should work:

RewriteCond %{QUERY_STRING} "^name=91-Sunflower(\s|%20)Crackers$" [NC]
RewriteRule ^recipes/recipe\.aspx?$ /recipes/? [NC,L,R]

No leading slash in RewriteRule and use (\s|%20) in RewriteCond to match a whitespace.

Upvotes: 1

Related Questions