Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/249.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何处理此URL?_Php_Url - Fatal编程技术网

Php 如何处理此URL?

Php 如何处理此URL?,php,url,Php,Url,我有http://www.example.com/contact-us.php 网址,这是完美的工作,但如果有人把http://www.example.com/contact-us.php/contact-us.php 它显示带有CSS的页面 我们可以为此向用户显示页面未找到消息吗http://www.example.com/contact-us.php/contact-us.php 网址?如果此页存在或不存在 更新: My.htacess文件-/public\u html/.htaccess:

我有http://www.example.com/contact-us.php 网址,这是完美的工作,但如果有人把http://www.example.com/contact-us.php/contact-us.php 它显示带有CSS的页面

我们可以为此向用户显示页面未找到消息吗http://www.example.com/contact-us.php/contact-us.php 网址?如果此页存在或不存在

更新:

My.htacess文件-/public\u html/.htaccess:

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*[^/])$ http://%{HTTP_HOST}/$1/ [L,R=301]

您可以在服务器上创建一个htaccess文件,并强制所有不直接指向此类文件的URL使用尾随斜杠。请检查是否:


您的站点似乎受到.htaccess设置的影响。请同时发布其内容。@Raptor整版内容?的内容。htaccess@Raptor我在服务器上没有.htacess文件相关:我在.htacess文件上放了上面的内容,但它没有working@RakeshShetty请用htaccess文件的完整代码更新您的问题,并提及其文件path@RakeshShetty你把这个单词拼错了htaccess文件。应该是。htaccess。重命名它并再次检查。这是一个有问题的输入错误,但在服务器上是。htaccess@RakeshShetty如果尚未启用mod_rewrite,请在启用mod_rewrite后使用更新的答案重试
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(.*)/$
    #Force Trailing slash
    RewriteRule ^((.*)[^/])$ $1/ [L,R=301]
</IfModule>