" HTTP://"在查询字符串不工作 [英] "http://" in query string does not work
问题描述
更新:
我在一个子域测试 - 无的.htaccess和PHP。
我创建了一个 index.html的
,并试图访问 / P = HTTP:/?
和 / P =的http://
。
我得到这个错误 / P =的http://
故宫
您没有权限访问/在此服务器上。
此外,试图使用ErrorDocument来处理请求404未找到时遇到错误。
在test.example.com端口80 Apache服务器
这排除了任何PHP或mod_rewrite的问题。什么是错的Apache?
案例1(不工作): mysite.com?p=http://
第2种情况(工作): mysite.com?p=http:/
如果有一个的http://
或的https://
或 FTP ://
的查询字符串,也将是一个错误,即使我的连接codeD吧。
我有一个的index.php
(入口脚本)和(用于测试这个错误)的test.php
。如果我访问的URL(通过是去的index.php
)使用的http://
的查询字符串里面, $ <$ C C $> _ GET 变量将即使有其他参数为空。如果我访问 test.php的P =的http://
,我会被重定向(没有在网址更改)的index.php
有一个错误(框架处理无效请求)。一旦更换的http:别的东西//
,一切工作正常 - 的test.php
显示了它的意思,所有的其他要求去的index.php
与 $ _ GET
填充。
我只是移动到一个新的主机(hostdime至HostGator的)后发现此错误。我无法重现这个其他地方(旧主机,本地服务器)。
感谢你。
我的.htaccess文件,剥夺了一些无关痛痒的code。
#使用PHP 5.3
将AddType应用/的X的httpd-php53的.php
#------------------------------------------------- ---------------------
#开始重写引擎
#------------------------------------------------- ---------------------
&LT; IfModule mod_rewrite.c&GT;
选项+的FollowSymLinks
RewriteEngine叙述上
#去除WWW。
#------------------------------------------------- -----------------
的RewriteCond%{} HTTPS!=上
的RewriteCond%{HTTP_HOST} ^ WWW \。(。+)$ [NC]
重写规则^ HTTP://%1%{REQUEST_URI} [R = 301,L]
#重写domain.com/foo - &GT; domain.com/foo/
#------------------------------------------------- -----------------
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{REQUEST_URI}(\ [A-ZA-Z0-9] {1,5} | / |#(*)。)!$
重写规则^(。*)$ / 1 $ / [R = 301,L]
#Yii的具体重写
#------------------------------------------------- -----------------
#如果一个目录或文件是否存在,直接使用它
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
#否则将其转发到index.php
重写规则。的index.php
&LT; / IfModule&GT;
#无-MultiViews,Apache将给予404的重写,如果相同名称的文件夹不存在
#------------------------------------------------- -----------------
选项-MultiViews
#------------------------------------------------- ---------------------
#UTF-8编码
#------------------------------------------------- ---------------------
任何东西#使用UTF-8编码担任文本/纯或为text / html
AddDefaultCharset UTF-8
#强制的UTF-8为一定数量的文件格式
AddCharset UTF-8的.html的.css .js文件的.xml .json的.rss .atom
#------------------------------------------------- ---------------------
#Gzip已融为一体pression
#------------------------------------------------- ---------------------
&LT; IfModule mod_deflate.c&GT;
...
&LT; / IfModule&GT;
&LT; IfModule mod_expires.c&GT;
...
&LT; / IfModule&GT;
&LT; IfModule mod_autoindex.c&GT;
选项-Indexes
&LT; / IfModule&GT;
#阻止访问隐藏,其名称以期目录。本
#包括使用版本控制系统,如颠覆或Git的目录。
&LT; IfModule mod_rewrite.c&GT;
的RewriteCond%{} SCRIPT_FILENAME -d
的RewriteCond%{} SCRIPT_FILENAME -f
重写规则(^ | /)\。 - [F]
&LT; / IfModule&GT;
#增加cookie安全性
&LT; IfModule php5_module&GT;
php_value session.cookie_httponly真
&LT; / IfModule&GT;
所以apperently这是主机上的问题。我接触HostGator的帮助和他们说,这是一个mod_security的问题。 如果你有麻烦试图解释,告诉他们来运行你给的链接apachetail命令。
这些链接可以帮助你一点
http://forums.hostgator.com/mod-安全和-403-错误-t71394.html
http://www.codingforums.com/showthread.php?t=233958
http://www.codingforums.com/showthread.php?t=244525
UPDATE:
I tested in a subdomain - no .htaccess and PHP.
I created a index.html
and tried accessing /?p=http:/
and /?p=http://
.
I got this error for /?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
This rules out any PHP or mod_rewrite problem. What is wrong with Apache?
Case 1 (does not work): mysite.com?p=http://
Case 2 (works): mysite.com?p=http:/
If there is a http://
or https://
or ftp://
in the query string, there would be an error, even if I encoded it.
I have an index.php
(entry script) and a test.php
(for testing this error). If I visit a URL (that goes via index.php
) with http://
inside the query string, the $_GET
variable would be empty even if there are other parameters. If I visit test.php?p=http://
, I would get redirected (no change in URL) to index.php
with an error (the framework handles invalid requests). Upon replacing http://
with something else, everything works fine - test.php
shows what it's meant to, all other requests goes to index.php
with $_GET
populated.
I only noticed this error after moving to a new host (hostdime to hostgator). I could not reproduce this anywhere else (old host, local server).
Thank you.
My .htaccess file, stripped of some irrelevant code.
# 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>
So apperently this is a problem on the host. I contacted HostGator for help and they said it was a mod_security problem. If you have trouble trying to explain, tell them to run apachetail command on the link you gave.
These links might help you a little
http://forums.hostgator.com/mod-security-and-403-errors-t71394.html
http://www.codingforums.com/showthread.php?t=233958
http://www.codingforums.com/showthread.php?t=244525
这篇关于&QUOT; HTTP://&QUOT;在查询字符串不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!