更新:
我在子域中进行了测试 - 没有 .htaccess 和 PHP。我创建了一个index.html
并尝试访问/?p=http:/
和/?p=http://
。我得到了这个错误/?p=http://
Forbidden
You don't have permission to access / on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache Server at test.example.com Port 80
这排除了任何 PHP 或 mod_rewrite 问题。阿帕奇有什么问题?
案例 1(不起作用):mysite.com?p=http://
案例2(作品):mysite.com?p=http://
如果查询字符串中有http://
或https://
或ftp://
,即使我对其进行了编码,也会出现错误。我有一个index.php
(入口脚本)和一个test.php
(用于测试此错误)。如果我在查询字符串中访问 URL(通过index.php
),即使有其他参数,该变量也会为空。如果我访问,我会被重定向(URL 没有变化)并出现错误(框架处理无效请求)。用其他东西替换后,一切正常 -显示它的含义,所有其他请求都被填充。http://
$_GET
test.php?p=http://
index.php
http://
test.php
index.php
$_GET
我只是在移动到新主机(hostdime 到 hostgator)后才注意到这个错误。我无法在其他任何地方(旧主机,本地服务器)重现这个。
谢谢你。
我的 .htaccess 文件,去掉了一些不相关的代码。
# Use PHP 5.3
AddType application/x-httpd-php53 .php
# ----------------------------------------------------------------------
# Start rewrite engine
# ----------------------------------------------------------------------
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# removes www.
# ------------------------------------------------------------------
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
# rewrite "domain.com/foo -> domain.com/foo/"
# ------------------------------------------------------------------
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
RewriteRule ^(.*)$ /$1/ [R=301,L]
# Yii specific rewrite
# ------------------------------------------------------------------
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
</IfModule>
# without -MultiViews, Apache will give a 404 for a rewrite if a folder of the same name does not exist
# ------------------------------------------------------------------
Options -MultiViews
# ----------------------------------------------------------------------
# UTF-8 encoding
# ----------------------------------------------------------------------
# Use UTF-8 encoding for anything served text/plain or text/html
AddDefaultCharset utf-8
# Force UTF-8 for a number of file formats
AddCharset utf-8 .html .css .js .xml .json .rss .atom
# ----------------------------------------------------------------------
# Gzip compression
# ----------------------------------------------------------------------
<IfModule mod_deflate.c>
...
</IfModule>
<IfModule mod_expires.c>
...
</IfModule>
<IfModule mod_autoindex.c>
Options -Indexes
</IfModule>
# Block access to "hidden" directories whose names begin with a period. This
# includes directories used by version control systems such as Subversion or Git.
<IfModule mod_rewrite.c>
RewriteCond %{SCRIPT_FILENAME} -d
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule "(^|/)\." - [F]
</IfModule>
# Increase cookie security
<IfModule php5_module>
php_value session.cookie_httponly true
</IfModule>