我在/domainName
文件夹中有.htaccess,其中包含规则Deny from all
和其他一些规则。
在此之后,如果我输入:
http://www.domainName.com - 我被正确重定向
http://www.domainName.com/uri - 我被正确重定向
domainName.com - 我收到错误You don't have permission to access / on this server. Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
结构:
/domainName/
/domainName/.htaccess
/domainName/public
/domainName/public/.htaccess
/domainName/.htaccess
RewriteEngine On
RewriteBase /
Options -MultiViews
Redirect https://domainName.com https://www.domainName.com/public/index\.php
Redirect https://www.domainName.com https://www.domainName.com/public/index\.php
Redirect http://domainName.com https://www.domainName.com/public/index\.php
Redirect http://www.domainName.com https://www.domainName.com/public/index\.php
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI}
#1# the error You don't have permission to access / on this server. Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
# Deny from all
#2#does not give errors, but i am not able to access https://www.domainName.com/public/index.php, dditionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
#<FilesMatch ".">
# Deny from all
#</FilesMatch>
#3# gives errors, about wrong configuration
# <DirectoryMatch ".">
# Deny from all
# </DirectoryMatch>
答案 0 :(得分:1)
似乎,在拒绝的情况下必须重定向:
Deny from all
ErrorDocument 403 https://www.somedomain.com/public/index.php/
如果在拒绝的情况下重定向,则不会出现url somedomain.com或www的错误。 somedomain.com
结构:
/domainName/
/domainName/.htaccess
/domainName/public
/domainName/public/.htaccess
在somedomain.com/public/中,应该有另一个.htaccess,whith rule Allow from all
。
全.htacess
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
Options -MultiViews
DirectoryIndex /public/index.php
#redirect to https
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
#[L,R=301]
# Now, rewrite any request to use www.
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Deny from all
ErrorDocument 403 https://www.somedomain.com/public/index.php/
在somedomain.com/public/中,应该有另一个.htaccess,whith rule Allow from all
。
错误您无权访问此服务器上的/。此外,尝试使用ErrorDocument处理请求时遇到403 Forbidden错误。