[英]Ho do i solve 403 Forbidden Error in zend framwork?
我已经使用zend framwork开发了我的网站
当我访问我的网站时我的网站上我的主页上出现403禁止错误
我没有在其他任何页面上收到此错误,只是在主页上出现错误
我的根目录上没有index.php文件,但我的实时服务器上的公用文件夹中有index.php文件
我已经写了.htacess文件来指向根目录下的公共文件夹
请让我知道如何解决此错误吗?bucause我已经完成了研发,并且有一些解决方案有人在说,因为您在根目录上没有index.php
但是当我放置索引文件时,我的网站无法正常工作
请帮我解决这个问题
以下是Root Director上的.htacess代码
# BEGIN SSL
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /public/$1
## EXPIRES CACHING ##
<IfModule mod_expires.c>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* ? [F,L]
ExpiresActive On
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##
您的RewriteRule应该以index.php为目标
例如
RewriteRule ^(.*)$ /public/index.php
或您的虚拟主机应具有
<Directory />
AllowOverride none
Require all granted
</Directory>
编辑:当然,在您应该排除资源之前,最后您的htaccess应该像这样:
RewriteEngine On
RewriteCond %{REQUEST_URI} !\.(?:css|js|jpe?g|gif|png)$ [NC]
RewriteRule ^(.*)$ /public/index.php [L]
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1
我尝试了以下解决方案及其工作
在根文件夹中创建一个index.php:
<?php
define('RUNNING_FROM_ROOT', true);
include 'public/index.php';
在根文件夹中创建一个.htaccess文件:
SetEnv APPLICATION_ENV production
RewriteEngine On
RewriteRule .* index.php
也许在测试时将APPLICATION_ENV设置为开发阶段:)
请注意,在引用静态文件时,baseUrl()视图助手现在指向您的根文件夹,而不是您的public /文件夹。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.