2017-05-28 66 views
0

我在规则Deny from all和其他一些规则中使用.htaccess文件夹中的/domainName文件夹。 在此之后,如果我输入:如何从具有权限`拒绝所有`的权限的文件夹中重定向,错误`您没有权限访问/在此服务器上`

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

看来,一个在否认的情况下重定向:

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,蒙山规则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,蒙山规则Allow from all

错误您无权访问/在此服务器上。此外,尝试使用ErrorDocument处理请求时遇到403 Forbidden错误。

相关问题