简体   繁体   中英

Assistance with htaccess redirect in Wordpress Network for 1 page on every site in the network

I am attempting to make a 301 redirect for one page that exists on every site in my network without having to write 200+ "Redirect 301" statements. I'm trying to learn a bit here, as it seems that mod_rewrite or Redirect Match could assist me, but I am a bit green in these areas.

The pseudo language of what I would need done: 301 redirect http://url.com/sitenameA/products-services/old-product/ to http://url.com/sitenameA/products-services/

301 redirect http://url.com/sitenameB/products-services/old-product/ to http://url.com/sitenameB/products-services/

So, where "sitenameA" and "sitenameB" are part of the URI, they must be preserved in the redirect, and take the user to the products-services page instead of the old-product page of the respective site.

As it is a Wordpress network site, there is only ONE htaccess (no ACTUAL directories) for each of the sites.

The answer to this problem was kicked off by the SO'er below. For SEO purposes, if you come across this problem, the answer is:

RewriteRule ^([^/]+)/products-services/sms-texting/?$ /$1/products-services/ [L,NC,R=301]

Place this rule as first rule in your DOCUMENT_ROOT/.htaccess file:

RewriteRule ^([^/]+/products-services)/old-product/?$ /$1 [L,NC,R=301]

OR

RewriteRule ^([^/]+)/products-services/old-product/?$ /$1/products-services/ [L,NC,R=301] 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM