我正在cPanel中的一个新插件域中设置一个快速的内部项目。这个特定的证书安装了SSL证书。我正在构建.htaccess,并添加了
<Files config.php>
对的指令
deny from all
因此无法访问我的config.php文件。我意识到将其存储在web根目录之外是理想的,但在这种情况下我做不到。
通常情况下,当我去
www.domain.com/config.php
在浏览器中,我会得到Apache默认的403 Forbidden页面。这是在同一服务器上的其他域上发生的情况。但在这种情况下,我得到了一个404未找到的错误,声明:
未找到
在此服务器上找不到请求的URL/403.shtml。
此外,在尝试使用ErrorDocument处理请求时,还遇到了404 Not Found错误。
如果我试图定义自定义错误文档,我通常会想到这一点,但在这种情况下,我没有!
唯一使该域与同一cPanel帐户中的所有其他域不同的是,它具有SSL证书。无论使用http还是https导航,这个404错误都是相同的。我试过清除缓存,但还是一样。
有人能在我下面的.htaccess中看到任何可能导致这种情况的东西吗?
DirectoryIndex /index.php
Options -Indexes +FollowSymLinks
ServerSignature Off
# PARSE PHP IN OTHER FILES
# AddType FOR PHP AS APACHE MODULE, AddHandler FOR CGI
AddType application/x-httpd-php .ics .xml
# ATTEMPT FORCE PDF DOWNLOAD
AddType application/octet-stream .pdf
# PREVENT ACCESS TO CONFIG
<Files config.php>
order allow,deny
deny from all
</Files>
# CACHING
# http://httpd.apache.org/docs/current/mod/mod_headers.html
<FilesMatch "\.(js|css|ico|png|gif|jpg)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"
#Header set Expires "Thu, 15 Apr 2011 20:00:00 GMT"
</FilesMatch>
# PREVENT ACCESS TO STATS UPDATE SCRIPT AS IT'S CLI ONLY
<Files stats_update.php>
order allow,deny
deny from all
</Files>
Redirect 302 /preview http://otherdomain.com/documents/preview
Redirect 302 /sample http://otherdomain.com/documents/preview
RewriteEngine On
# REWRITE NON-WWW TO WWW
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301]
RewriteRule ^about/?$ /index.php [L]
RewriteRule ^contact/?$ /contact.php [L]
RewriteRule ^home/?$ /home.php [L]
RewriteRule ^order/?$ /order.php [L]
# MAINTAINANCE
#RewriteCond %{REMOTE_HOST} !^123\.123\.123\.123
#RewriteCond %{REQUEST_URI} !^/maintainance\.html$
#RewriteRule ^(.*)$ /maintainance.html [R=302,L]
编辑:
这可能与cPanel处理主域和附加域的方式有关吗?
在cPanel帐户中,您有一个文件所在的主域
public_html
然后定义文件所在的插件域(或子域)
public_html/addondomain.com/
将在的主域的.htaccess
public_html/.htaccess
正在影响/覆盖位于
public_html/addondomain.com/.htaccess
?
我知道.htaccess确实是通过目录级联的,但这种情况甚至在特定域的DocumentRoot之上吗?例如:在这个插件域的情况下?
编辑2:
仅供参考,这里是对这两个HTTP请求的响应,绕过了任何缓存
root@vps [/home/username]#curl -i 'http://www.mydomain.com/config.php'
HTTP/1.1 403 Forbidden
Date: Sun, 16 Sep 2012 19:05:10 GMT
Server: Apache
Content-Length: 331
Content-Type: text/html; charset=iso-8859-1
root@vps [/home/username]# curl -i 'http://mydomain.com/config.php'
HTTP/1.1 301 Moved Permanently
Date: Sun, 16 Sep 2012 19:05:20 GMT
Server: Apache
Location: http://www.mydomain.com/403.shtml
Content-Length: 244
Content-Type: text/html; charset=iso-8859-1
你可以看到第二个得到301重定向,但它正在重定向到403.shtml。因此,在重写到www之前,403.shtml已经被注入。