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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744839770a4596484.html
评论列表(0条)