wordpress 不同的文件夹作为网站子文件夹
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6307047/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Different folder as website subfolder
提问by nevvermind
I need some help with URL rewriting. The case is similar with this one.
我需要一些 URL 重写方面的帮助。情况与此类似。
I have a working Zend Framework site. Now I must add a blog in Wordpress (also working). I've chosen notto indulge in ZF controller-/action-/route-making; I've seen a couple of tutorials about this and I consider them too much for a "plain" redirection. Now, about that "redirection"...
我有一个可用的 Zend Framework 站点。现在我必须在 Wordpress 中添加一个博客(也可以工作)。我选择不沉迷于 ZF 控制器-/动作-/路线制作;我已经看过一些关于这个的教程,我认为它们对于“普通”重定向来说太过分了。现在,关于那个“重定向”......
This is how it should look like:
它应该是这样的:
www.site.com
(points to/var/www/zf
)www.site.com/blog
(points to/var/www/wp
)
www.site.com
(指向/var/www/zf
)www.site.com/blog
(指向/var/www/wp
)
I know that I should stop www.site.com/blog
to enter ZF's innards and I'm currently doing this with RewriteRule ^blog - [NC,L]
in its .htaccess, but that's about it. As @jasonsaid, "just pass it through to Wordpress", but I don't know how exactly to do that.
我知道我应该停下www.site.com/blog
来进入 ZF 的内部,我目前正在RewriteRule ^blog - [NC,L]
它的 .htaccess 中这样做,但仅此而已。正如@jason所说,“只需将其传递给 Wordpress”,但我不知道具体该怎么做。
Related question:
I never tried it, but does Apache support this in two differentvhosts?ServerName www.site.com
(vhost for ZF site)ServerName www.site.com/blog
(vhost for WP site)
相关问题:
我从未尝试过,但是 Apache 是否在两个不同的虚拟主机中支持此功能?ServerName www.site.com
(用于 ZF 站点的ServerName www.site.com/blog
vhost )(用于 WP 站点的 vhost)
回答by rightstuff
www.site.com (points to /var/www/zf)
www.site.com/blog (points to /var/www/wp)
www.site.com(指向 /var/www/zf)
www.site.com/blog(指向 /var/www/wp)
The easiset way to achive this, where you want a sub-url to point outside the VirtualHost's DocumentRoot directory, is to create an Alias...
实现此目的的最简单方法是创建一个别名...
Inside the VirtualHost block add:
在 VirtualHost 块内添加:
Alias /blog /var/www/wp
<Directory /var/www/wp>
Options All
AllowOverride All
order allow,deny
allow from all
</Directory>
*This assumes you have PHP enabled in some way for that directory.
*这假设您以某种方式为该目录启用了 PHP。
回答by Femi
The ServerName trick will not work: you can not have path names in a ServerName directive.
ServerName 技巧不起作用:在 ServerName 指令中不能有路径名。
For mod_rewrite you should be able to get away with something like this:
对于 mod_rewrite,你应该能够摆脱这样的事情:
RewriteEngine on
RewriteBase /
RewriteRule ^blog/(.*)$ wp/ [L]
RewriteRule ^(.*)$ zf/ [L]