1

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.

1
  • I'm not a developer. Just a lay person who has found numerous helpful replies for similar redirect questions. Currently have no attempts. Commented Nov 4, 2016 at 18:03

1 Answer 1

1

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]
Sign up to request clarification or add additional context in comments.

3 Comments

what is THE_REQUEST ?
It's a predefined server variable. Please read the mod-rewrite documentation : httpd.apache.org/docs/current/mod/mod_rewrite.html
Thanks so much for the assistance. I apologize for what may be a dumb question, but I am not a tech person. Just the website owner. We have constructed an htaccess file that is about 3,500 lines long now. Its a 17 year old website with multiple redesigns/migrations. I have all the "RewriteRules", "RedirectMatch", and "RewriteConds" in the top half of the file. The WordPress stuff in the middle. And the standard "Redirect 301"s in the bottom half. Do you see any risk of adding these to the top half, causing things below them to stop working, or change function at all?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.