1

我在 Ubuntu 上使用 zend 框架和 Apache 服务器。当我在本地主机上尝试我的网站时,我使用以下网址

例如:

http://test.dev/authentication/login
http://test.dev/student/profile

其中'authentication'指的是AuthenticationController,'login'指的是loginAction。“student”指的是 StudentController,“profile”指的是 profileAction。

问:现在我想在我的网站上使用 phpBB 论坛。我必须使用以下 URL 来启动我的网站的 phpBB 论坛。

http://localhost/test/forum/

'test' 是我的主要项目(网站)目录。我想为 phpBB 论坛使用以下 URL。

http://test.dev/forum/

如何配置我的项目以使用上述 URL 打开 phpBB 论坛?我应该创建一个控制器吗?

谢谢

4

3 回答 3

2

我猜您正在将 apache mod_rewrite 与您的 ZF 应用程序一起使用。

最简单的解决方案是在 forum/ 目录下放置一个新的 .htaccess 文件并关闭重写引擎

RewriteEngine Off 

这是有效的,因为 Apache 首先在请求的目录中查找 .htaccess 文件,如果找不到,他会在父文件夹中查找,依此类推,直到到达公共目录。当您请求 /forum/ 时,他会在那里找到 .htaccess 文件并关闭 RewriteEngine。

于 2009-11-02T10:43:20.583 回答
1

一段时间后,我找到了答案。我刚刚将我的“论坛”文件夹放在“公共”文件夹中,它对我有用,而无需更改我的 .htaccess 文件。

这是我的设置:

我的目录结构现在是这样的:

/var/www/test/public/index.php
/var/www/test/public/.htaccess
/var/www/test/public/forum

我的 httpd.conf 条目是这样的:

<VirtualHost 127.0.0.1>
    ServerName test.dev
    DocumentRoot 'C:\wamp\www\test\public'
</VirtualHost>

我的 .htaccess 文件是这样的(它控制文件夹和控制器/操作 URL):

SetEnv APPLICATION_ENV development

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

上面 .htaccess 文件中的最后一行允许我在 URL 中使用没有 index.php 的 URL。

完成上述设置后,我可以正确使用以下 URL:

http://test.dev/authentication/login
http://test.dev/student/profile
http://test.dev/forum/

在上面的 URL 中,“authentication”和“student”是控制器。“登录”和“个人资料”是操作,论坛是目录

欢迎评论。谢谢

于 2009-11-12T19:23:02.673 回答
1

这也将起作用:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(js|ico|gif|jpg|png|css)$ /index.php

如果您将 phpBB 放在公用文件夹中,网络服务器将能够看到它,并且此代码的​​第二两行将从重写中排除“真实​​文件”和“真实文件夹”,这是您想要的forum文件夹。显然最后一次,将所有框架流量推送到index.php文件。

于 2010-01-02T13:38:08.567 回答