与网站子文件夹不同的文件夹

发布于 2024-11-14 21:21:36 字数 907 浏览 5 评论 0原文

我需要一些有关 URL 重写的帮助。情况与这个类似。

我有一个正在运行的 Zend Framework 站点。现在我必须在 Wordpress 中添加一个博客(也可以工作)。我选择沉迷于ZF控制器/动作/路线制定;我看过一些关于此的教程,我认为它们对于“简单”重定向来说太多了。现在,关于“重定向”...

它应该是这样的:

  • www.site.com(指向/var/www/zf
  • www.site.com/blog (指向 /var/www/wp

我知道我应该停止 www.site.com/blog 进入ZF 的内部结构,我目前正在做这个RewriteRule ^blog - [NC,L] 在其 .htaccess 中,但仅此而已。正如@jason所说,“只需将其传递到Wordpress”,但我不知道具体该怎么做。

相关问题:
我从未尝试过,但是 Apache 在两个不同的虚拟主机中支持此功能吗?
服务器名称 www.site.com(ZF 站点的虚拟主机)
服务器名称 www.site.com/blog(WP 网站的虚拟主机)

I need some help with URL rewriting. The case is similar with this one.

I have a working Zend Framework site. Now I must add a blog in Wordpress (also working). I've chosen not to 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"...

This is how it should look like:

  • www.site.com (points to /var/www/zf)
  • www.site.com/blog (points to /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 @jason said, "just pass it through to Wordpress", but I don't know how exactly to do that.

Related question:
I never tried it, but does Apache support this in two different vhosts?
ServerName www.site.com (vhost for ZF site)
ServerName www.site.com/blog (vhost for WP site)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半暖夏伤 2024-11-21 21:21:36

www.site.com(指向/var/www/zf)

www.site.com/blog(指向/var/www/wp)

实现此目的的最简单方法,您希望子 URL 指向外部VirtualHost 的 DocumentRoot 目录,用于创建别名...

在 VirtualHost 块内添加:

Alias /blog /var/www/wp

<Directory /var/www/wp>
    Options All
    AllowOverride All
    order allow,deny
    allow from all
</Directory>

*这假设您以某种方式为该目录启用了 PHP。

www.site.com (points to /var/www/zf)

www.site.com/blog (points to /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:

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.

瑕疵 2024-11-21 21:21:36

ServerName 技巧不起作用:ServerName 指令中不能包含路径名。

对于 mod_rewrite 你应该能够摆脱这样的事情:

RewriteEngine on
RewriteBase /
RewriteRule ^blog/(.*)$ wp/$1 [L]
RewriteRule ^(.*)$ zf/$1 [L]

The ServerName trick will not work: you can not have path names in a ServerName directive.

For mod_rewrite you should be able to get away with something like this:

RewriteEngine on
RewriteBase /
RewriteRule ^blog/(.*)$ wp/$1 [L]
RewriteRule ^(.*)$ zf/$1 [L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文