PHPZend、MVC Web 应用程序和 Apache 重写问题

发布于 2024-09-06 20:30:41 字数 1695 浏览 0 评论 0原文

我正在使用 Zend 框架构建 MVC Web 应用程序,并且遇到了一个奇怪的问题。

如果我以一种方式配置了 httpd.conf VirtualHost 部分和网站的根 .htaccess 文件,Apache 不会读取 index.php 文件(即 www[dot]mywebsite[dot]com/ 失败),不会向重写写入任何内容记录并将此错误放入一般错误日志文件中:

Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /hg/software/cims/src/public/

然而,再次使用相同的 httpd.conf 和 .htaccess 设置,我可以进入我的登录屏幕(即 www[dot]mywebsite[dot]com/account/login 成功)并且重写日志中有大量信息。

但是,如果我将 .htaccess 重写命令移至 VirtualHost 下的 Directory 块并将 AllowOverride 设置为“None”,则会发生相反的情况。 Apache读取并显示index.php(即www[dot]mywebsite[dot]com/成功),但它不会带我进入登录屏幕并尝试直接访问登录屏幕失败(即www[dot]mywebsite[dot ]com/account/登录失败)。

第一个错误情况的相关设置:

httpd.conf:

RewriteEngine On
RewriteLog /hg/hgweb/logs/appdev_rewrite.log
RewriteLogLevel 1

<VirtualHost *:80>
    SetEnv ETSSERVER mywebsite
    SetEnv VHOST appdev
    SetEnv APPLICATION_ENV development
    ServerName appdev
    ServerAlias appdev.mywebsite.com
    ServerPath /hg/software/appdev/src/public/
    DocumentRoot /hg/software/appdev/src/public/
    ErrorLog /hg/hgweb/logs/appdev_error.log
    CustomLog /hg/hgweb/logs/appdev_access.log common
    <Directory />
        Options Indexes FollowSymLinks SymLinksIfOwnerMatch
        AllowOverride All
        Order Allow,Deny
        Allow from All
    </Directory>
</VirtualHost>

.htaccess:

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

非常感谢任何有关可能导致此问题的原因的见解。

I'm in the process of building an MVC web application using the Zend framework and I've encountered an odd problem.

If I have the httpd.conf VirtualHost section and the web site's root .htaccess file configured one way, Apache does not read the index.php file (i.e. www[dot]mywebsite[dot]com/ fails), writes nothing to the rewrite log and places this error in the general error log file:

Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /hg/software/cims/src/public/

Yet, again with the same httpd.conf and .htaccess settings, I can get to my login screen (i.e. www[dot]mywebsite[dot]com/account/login succeeds) and there is plenty of information in the rewrite log.

However, if I move the .htaccess rewrite commands to the Directory block under VirtualHost and set AllowOverride to "None", the reverse happens. Apache reads and displays index.php (i.e. www[dot]mywebsite[dot]com/ succeeds), but it does not take me to the login screen and attempts to directly access the login screen fail (i.e. www[dot]mywebsite[dot]com/account/login fails).

Thee relevant settings for the first error condition:

httpd.conf:

RewriteEngine On
RewriteLog /hg/hgweb/logs/appdev_rewrite.log
RewriteLogLevel 1

<VirtualHost *:80>
    SetEnv ETSSERVER mywebsite
    SetEnv VHOST appdev
    SetEnv APPLICATION_ENV development
    ServerName appdev
    ServerAlias appdev.mywebsite.com
    ServerPath /hg/software/appdev/src/public/
    DocumentRoot /hg/software/appdev/src/public/
    ErrorLog /hg/hgweb/logs/appdev_error.log
    CustomLog /hg/hgweb/logs/appdev_access.log common
    <Directory />
        Options Indexes FollowSymLinks SymLinksIfOwnerMatch
        AllowOverride All
        Order Allow,Deny
        Allow from All
    </Directory>
</VirtualHost>

.htaccess:

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

Any insight into what may be causing this is greatly appreciated.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文