DigitalSM
DigitalSM

Reputation: 113

Redirect to specific page - .htaccess, wordpress

i would like to know how to redirect every url that comes after /old-articles/ to my /blog/ page. ex.: https://www.mywebsite.com/old-articles/some-article/ - - > https://www.mywebsite.com/blog/ I have tried many things in my .htacces file but i can not find a solution. Apache server - wordpress site

i have already tried: RewriteEngine on

RewriteRule ^old-articles(.*)$ /blog$1 [R=301,NC,L]

Redirect 301 /old-articles/* /blog/

Redirect 301 /old-articles/(.*)$ /blog$1

Redirect 301 /old-articles(.*)$ /blog$1

Redirect 301 /old-articles(.*)$ /blog/

I have a lot of links that i want to redirect them to blog, like: /faq-category/* --> /blog/ i have tried the same things for that too. But the result is always the same, "Page not found", without redirecting to blog.

Upvotes: 0

Views: 270

Answers (1)

Xhynk
Xhynk

Reputation: 13880

This should be fairly similar to the standard "redirect all traffic to new domain" .htaccess code, which generally looks something like:

RewriteEngine on 
RewriteRule ^(.*)$ https://new-website.com/$1 [R=301,L]

However since you just want to redirect a subdirectory you can do something like:

RewriteEngine on
RewriteRule ^old-articles(.*)$ /blog$1 [R=301,NC,L]

Upvotes: 0

Related Questions