-1

1) I have a Wordpress multisite subdomain installation with about 100 sites in the network.

Network Admin - Sites (All Sites) shows them like this:

main site: "www.domain-name.com"
all other sites: "subdomain-name.domain-name.com"

there is also a domain mapping plugin, so they all get access as separate urls:

domain-name1.com
domain-name2.com
...
domain-name100.com

2) Currently urls on all blogs are set to:

domain-name.com/2012/10/26/post-name
domain-name.com/category/category-name

(I used today's date as an example)

This is also the way domains show in Google and Bing search results

3) I am going to remove "2012/10/26/" and "category/" from the urls, so they are gonna look like this:

domain-name.com/post-name
domain-name.com/category-name

...and I need to have a rewrite rule that takes care of redirecting people coming from serps to these new urls

4) I have something like this right now:

RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)$ http://domain.com/$4 [L,R=301]

RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)$ http://domain.com/$4 [L,R=301]

but I am not sure if it is correct / if it is gonna work right, and also I need to have a rule for all 100 websites, and not just one. These versions (only one of them was meant to be used) dont include the "category/" part either.

5) If somebody would have an idea how to do that it would be great (one or two rewrite rules for all sites would be probably best).

Thank you in advance for any info.

4

1 回答 1

0

You can simplify your regex for the RewriteRule using \d to match digits and only using a match group on the post-name. If this behavior is the same for all of the domains, you can just omit the domain from your RewriteCond and RewriteRule:

RewriteRule ^\d{4}/\d{2}/\d{2}/(.*)$ $1 [L,R=301]
RewriteRule ^category/(.*)$ $1 [L,R=301]

You can test the above rules and resulting URLs with http://htaccess.madewithlove.be/

于 2012-10-27T02:50:47.160 回答