PHP 变量的 URL 中的问号会导致链接损坏。知道为什么吗?

发布于 2024-09-28 07:39:34 字数 1203 浏览 2 评论 0原文

我不知道过去发生了什么变化——这曾经有效:

像下面这样访问我的服务器上的 URL 不起作用: http://www.domain.com/folder/file.php?variable=a&variable2=b

我得到了一个“未找到 在此服务器上找不到请求的地址 406.shtml。”信息。

但是,如果我访问它,它会起作用: http://www.domain.com/folder/file.php

添加问号file.php 之后是导致它崩溃的原因。我以前从未遇到过这样的问题。起初我以为 .htaccess 与此有关,但我知道事实上它过去根本没有被编辑过。

有什么想法吗?我正在使用 CakePHP,但我怀疑这与它有什么关系;这以前有效过。欢迎所有建议!

编辑: /app/webroot .htaccess 文件有这样的内容:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

</IfModule>

据我所知,这根本没有改变,并且 URL 可以使用它。 /public_html/ 下的 .htaccess 文件包含以下内容:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
<IfModule mod_rewrite.c>
   RewriteEngine on


   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]


</IfModule>

I don't know what changed in the past--this used to work:

Accessing a URL on my server like the following, doesn't work: http://www.domain.com/folder/file.php?variable=a&variable2=b

I'm getting a "Not found The requested address 406.shtml was not found on this server." message.

However, if I access this, it works:
http://www.domain.com/folder/file.php

Adding the question mark after file.php is what makes it break. I have never experienced a problem like this before. At first I thought that .htaccess had something to do with it, but I know as a fact that it hasn't been edited at all in the past.

Any ideas? I'm using CakePHP, but I doubt that has anything to do with it; this has worked before. All suggestions are welcome!

EDIT:
The /app/webroot .htaccess file has this:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

</IfModule>

As far as I know, this hasn't changed at all, and the URL worked with this. The .htaccess file right under /public_html/ contains this:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
<IfModule mod_rewrite.c>
   RewriteEngine on


   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]


</IfModule>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光清浅 2024-10-05 07:39:34

你的 apache 配置有错误。它试图向您提供 406 错误页面,但找不到它。如果您修复了该问题,您可能会收到更具信息性的错误。

此链接可能会帮助您解决问题的根源:http://urbangiraffe。 com/2005/08/20/mysterious-406-error/

也可能是由 mod_security 引起的。如果这不是您的服务器,您应该询问您的托管提供商。

You've got an error in your apache config. It's attempting to give you the 406 error page, but can't find it. If you fix that you may get a more informative error.

This link may help you with the root of the problem: http://urbangiraffe.com/2005/08/20/mysterious-406-error/

It could also be caused by mod_security. If it's not your server you should ask your hosting provider.

呆萌少年 2024-10-05 07:39:34

99.9% 的可能性是由于 htaccess 文件的更改造成的。某些内容正在检查查询字符串并重定向到或尝试加载不存在的文件。

99.9% probability that this is being caused by a change in your htaccess file. Something is checking for a query string and redirecting to or trying to load a file that doesn't exist.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文