Linux 服务器中的 Zend Framework 配置


Zend Framework Configuration in Linux server

我在配置.htaccess文件Zend框架时遇到问题。在我的本地服务器中,它运行正常,正在运行 apache 和 windows 7。

但是当我尝试在实时服务器中运行它时,它会显示403 Forbidden

这是我的 .htaccess 配置

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^'.htaccess$ - [F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteCond $1 !^(favicon'.ico|favicon'.png|media|robots'.txt|crossdomain'.xml|css|js)
RewriteRule ^public/.*$ /public/index.php [NC,L]
Options -Indexes

几乎总是原因是Apache用户对这些文件没有读取权限。

我认为如果你简化你的.htaccess规则,你可以让事情正常工作。

由于您的 Zend Framework index.php 文件大概是 public_html/public 的,请根据您的配置打开httpd.confhttpd-vhosts.conf,并将/public添加到您的DocumentRoot中。

这样,public将成为 Web 可访问目录,其下的所有内容(包括 ZF 应用程序文件)都将受到保护。

进行该更改后,将所有.htaccess文件替换为标准的 Zend Framework 重写规则:

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

此外,请确保以下所有项目都为真,否则可能无法正常运行:

  • httpd.conf中为您的public_html目录设置AllowOverride All
  • Chmod 644适用于.htaccess和所有 PHP 脚本,755适用于大多数目录
  • 索引中的APPLICATION_PATH.php是正确的

希望有帮助。