- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在 cPanel 的新插件域中设置一个快速内部项目。这个特定的安装了 SSL 证书。我正在构建我的 .htaccess 并添加了 <Files config.php>
指令deny from all
这样我的 config.php 文件就无法访问。我意识到将其存储在网络根目录之外是理想的选择,但在这种情况下我不能。
通常我会期望当去 www.domain.com/config.php
时在浏览器中我会得到 Apache 的默认 403 Forbidden 页面。这是同一服务器上的其他域上发生的情况。但在这种情况下,我收到 404 未找到错误,指出:
Not Found
The requested URL /403.shtml was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
如果我试图定义自定义错误文档,我通常会期望这一点,但在这种情况下,我不会!
使该域与同一 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。所以403.shtml在重写www之前就已经被注入(inject)了。发生了。
最佳答案
这在普通 Apache 安装中无法重现,因此我开始进一步询问 cPanel。因此,经过大量的研究后,我找到了这个问题。 cPanel 确实为您设置了 ErrorDocument 指令,但它一点也不聪明。特别是当它将 ErrorDocuments 设置为与 Apache 默认值明显相同的文档时。
由于 ErrorDocument cPanel 屏幕为空白,因此发生这种情况的位置并不明显。
cPanel 的 httpd.conf 是由相当多的包含的配置构建的,并且隐藏着......
/usr/local/apache/conf/includes/errordocument.conf
...
# 403 - Forbidden
ErrorDocument 403 /403.shtml
这就是 403.shtml 出现在请求中的地方。 cPanel 为我设置了错误文档。为了避免在 403 上看到 404 的困惑,我设置了自己的 403 错误消息,这样至少它们是一致的。
我希望这可以帮助别人!
关于apache - htaccess 文件拒绝所有,重定向到 404 在 403.shtml 上找不到,但未定义自定义错误页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12192681/
我正在尝试使用谷歌浏览器的 Trace Event Profiling Tool分析我正在运行的 Node.js 应用程序。选择点样本后,我可以在三种 View 之间进行选择: 自上而下(树) 自上而
对于一个可能是菜鸟的问题,我们深表歉意,但尽管在 SO 上研究了大量教程和其他问题,但仍找不到答案。 我想做的很简单:显示一个包含大量数据库存储字符串的 Android ListView。我所说的“很
我已经开始了一个新元素的工作,并决定给 Foundation 5 一个 bash,看看它是什么样的。在创建带有水平字段的表单时,我在文档中注意到的第一件事是它们使用大量 div 来设置样式。所以我在下
我有一个 Windows 窗体用户控件,其中包含一个使用 BeginInvoke 委托(delegate)调用从单独线程更新的第 3 方图像显示控件。 在繁重的 CPU 负载下,UI 会锁定。当我附加
我有一堆严重依赖dom元素的JS代码。我目前使用的测试解决方案依赖于 Selenium ,但 AFAIK 无法正确评估 js 错误(addScript 错误不会导致您的测试失败,而 getEval 会
我正在制作一款基于滚动 2D map /图 block 的游戏。每个图 block (存储为图 block [21][11] - 每个 map 总共 231 个图 block )最多可以包含 21 个
考虑到以下情况,我是前端初学者: 某个 HTML 页面应该包含一个沉重的图像(例如 - 动画 gif),但我不想强制客户缓慢地等待它完全下载才能享受一个漂亮的页面,而是我更愿意给他看一个轻量级图像(例
我正在设计一个小软件,其中包括: 在互联网上获取资源, 一些用户交互(资源的快速编辑), 一些处理。 我想使用许多资源(它们都列在列表中)来这样做。每个都独立于其他。由于编辑部分很累,我想让用户(可能
我想比较两个理论场景。为了问题的目的,我简化了案例。但基本上它是您典型的生产者消费者场景。 (我关注的是消费者)。 我有一个很大的Queue dataQueue我必须将其传输给多个客户端。 那么让我们
我有一个二元分类问题,标签 0 和 1(少数)存在巨大不平衡。由于测试集带有标签 1 的行太少,因此我将训练测试设置为至少 70-30 或 60-40,因此仍然有重要的观察结果。由于我没有过多地衡量准
我是一名优秀的程序员,十分优秀!