StackBurger
StackBurger

Reputation: 73

Redirecting URLs with Multiple Parameters via HTACCESS

How would I do this 301 redirect in my htaccess file?

OLD URLs

http://www.domain.com/newsletter/modules.php?op=modload&name=News&file=article&sid=221

http://www.domain.com/newsletter/modules.php?op=modload&name=News&file=article&sid=224

NEW URLs

For 221 - https://www.domain.com/news/

For 224 - https://www.domain.com/treatments/laser-comb/iso-certification/

Explanation: Basically everything is the same in the OLD urls except for the article ID number at the end.

Upvotes: 1

Views: 731

Answers (1)

Amit Verma
Amit Verma

Reputation: 41249

At the top of your htaccess file, add the following :

RewriteEngine on

#1)
RewriteCond %{THE_REQUEST} /newsletter/modules\.php\?op=modload&name=News&file=article&sid=221 [NC]
RewriteRule ^ http://www.domain.com/news/? [L,R=301]
#2)
RewriteCond %{THE_REQUEST} /newsletter/modules\.php\?op=modload&name=News&file=article&sid=224 [NC]
RewriteRule ^ https://www.domain.com/treatments/laser-comb/iso-certification/? [L,R=301]

Upvotes: 1

Related Questions