PHPZend、MVC Web 应用程序和 Apache 重写问题
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论