在URL脚本名称后斜线 [英] Slash after script name in URL

查看:143
本文介绍了在URL脚本名称后斜线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我自己的网站上有一个奇怪的错误:我可以把任何东西与斜线的URL的末尾,它不显示404错误,它做工精细。例如:

My own site has one weird bug: I can put anything with slash in the end of URL and it doesn't show 404 error, it working fine. For example:


  1. 这是正常的网址: http://site.com/path/index.php

我把/aaa.php到底:的http:/ /site.com/path/index.php/aaa.php - 它告诉我正常的URL(如在1)

I put "/aaa.php" in the end: http://site.com/path/index.php/aaa.php - and it show me normal URL (like in 1).

这是什么?如何消除这种行为呢?我希望看到的404错误在第二种情况下。

What is it? How to remove this behaviour? I want to see 404 error in second case.

的Apache / 2.2.24(FreeBSD的)
PHP 5.4.10

Apache/2.2.24 (FreeBSD) PHP 5.4.10

推荐答案

这是(几乎)所有的服务器端与web服务器脚本的默认行为(如PHP和安培;其他)的支持。
你可以用PHP尝试一下,在这种情况下检查是否$ _ SERVER [REQUEST_URI]匹配$ _ SERVER [SCRIPT_NAME],但仅如果你不使用URL重写。
您也可以禁用多视图选项,大奖赛指出。

It is default behaviour of (almost) every webserver with serverside scripting (like PHP & others) support. You can try it with PHP, in that case check if $_SERVER["REQUEST_URI"] matches $_SERVER["SCRIPT_NAME"], but that works only if you don't use URL rewriting. You can also disable MultiViews option, as Prix pointed out.

这篇关于在URL脚本名称后斜线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆