Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
.htaccess 如何对url为';s,其中包含的文件名不是在末尾,而是在斜杠之间_.htaccess_Url_Redirect_Mod Rewrite - Fatal编程技术网

.htaccess 如何对url为';s,其中包含的文件名不是在末尾,而是在斜杠之间

.htaccess 如何对url为';s,其中包含的文件名不是在末尾,而是在斜杠之间,.htaccess,url,redirect,mod-rewrite,.htaccess,Url,Redirect,Mod Rewrite,我想在htacess for Apache 2.4.29中对如下URL进行内部重定向: RewriteRule (?:^|/)[\w-]+(?:\.[\w-]+)+/ index.php?route=error/not_found [L,QSA] example.com/file.php/dir/dirnext example.com/dir/file.html/ example.com/dir/dirnext/file.jpg/onemoredir/ 等等 我的意思是,如果url中出现两

我想在htacess for Apache 2.4.29中对如下URL进行内部重定向:

RewriteRule (?:^|/)[\w-]+(?:\.[\w-]+)+/ index.php?route=error/not_found [L,QSA]
  • example.com/file.php/dir/dirnext
  • example.com/dir/file.html/
  • example.com/dir/dirnext/file.jpg/onemoredir/
  • 等等
我的意思是,如果url中出现两个斜杠之间的文件名->重定向到404页面。我尝试过这个,但它不起作用:

RewriteRule ^/(.*)/$ index.php?route=error/not_found [L]

您可以使用如下规则:

RewriteRule (?:^|/)[\w-]+(?:\.[\w-]+)+/ index.php?route=error/not_found [L,QSA]

nginx
实际上不支持
mod_rewrite
.htaccess
anubhava,对不起-我的错误。服务器是apache 2.4.29确定您是否希望对任何看起来像文件名的内容进行内部重写,例如
example.com/foo/xyz.123/bar
,即使
xyz.123
不作为文件存在。@anubhava,是的。