admin管理员组

文章数量:1410725

I have a multisite WP instance set up to use subdirectories. I have a few pages that should have URLs on each site. The content will be (almost) the same, so I wanted to just make the pages once and rewrite requests to them from other sites. Allowing for future expansion, I thought I'd rewrite all pages that start with a given pattern ("foo-" in my example) to a common site. For example:

should rewrite to

.php?pagename=foo-path&market=dallas ,

and

should rewrite to

.php?pagename=foo-path&market=el-paso ,

but

should rewrite to .php?pagename=bar-path as usual.

Reading up on the problem, I don't think it's possible to rewrite the request to another site using add_rewrite_rule(), which is a shame, because I was trying to make a plugin to solve this problem. Can anyone confirm or deny this?

Presuming it's not possible to do what I describe with add_rewrite_rule(), I'll have to modify .htaccess. It's currently at the default for WP subdirectory multisite; can anyone offer a suggestion on how to modify it to meet my goal?

Update: I tried adding the following condition and rule to my .htaccess:

RewriteCond %{REQUEST_URI} !^/common-site/ [NC]
RewriteRule ^([_0-9a-zA-Z-]+)/?(foo-.+)$ common-site/$2?market=$1

When I look at the mod_rewrite log, it seems to be working:

rewrite 'dallas/foo-path/' -> 'common-site/foo-path/?market=dallas'

but I get a 404, even though foo-path exists on common-site.

本文标签: multisiteRewriting request to another site