Apache 403错误页面未使用.htaccess中的F标志
我试图只允许https连接到我的子域。My.htaccess当前看起来像这样:Apache 403错误页面未使用.htaccess中的F标志,apache,.htaccess,mod-rewrite,https,httpforbiddenhandler,Apache,.htaccess,Mod Rewrite,Https,Httpforbiddenhandler,我试图只允许https连接到我的子域。My.htaccess当前看起来像这样: Options -MultiViews -Indexes ErrorDocument 403 /403.php ErrorDocument 404 /404.php RewriteEngine On #Only allow https requests RewriteCond %{HTTPS} off RewriteCond %{REQUEST_URI} !/docs/?(.*)$ [NC] RewriteRul
Options -MultiViews -Indexes
ErrorDocument 403 /403.php
ErrorDocument 404 /404.php
RewriteEngine On
#Only allow https requests
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !/docs/?(.*)$ [NC]
RewriteRule ^ - [F]
#Docs file rewrite
RewriteRule ^docs/?$ /Docs.php
如果我删除仅允许https请求
部分并尝试访问目录(例如http://foo.bar.com/images/
),我的漂亮403页面显示出来。但是如果我将该部分保留在中并转到子域根(例如http://foo.bar.com/
),我得到了默认的错误页面,这与htaccess完全禁止访问所有文件有关吗
示例:
通过安全连接,403页可以工作-
但通过一个非安全页面,它是默认页面-
在使用重写规则之前,重写引擎应该在
上:
Options -MultiViews -Indexes
ErrorDocument 403 /403.php
ErrorDocument 404 /404.php
RewriteEngine On
#Only allow https requests
RewriteCond %{HTTPS} off
RewriteRule !^docs - [NC,F]
RewriteRule ^docs/?$ /Docs.php [L,NC]
这仍然会导致显示默认页面。现在,我的问题中包含了一些示例,也许您可以看看这些示例。
http://api.subjectplanner.co.uk/assets
显示403(禁止)错误,这是由于该规则适用,因为该规则仅适用于非https
。还要记住,上述第一条规则不会影响https
请求。@anubhava,谷歌搜索总是把你的答案放在最上面,先生:)干杯:)