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
如何检查URL以在.htaccess上包含特殊字符_.htaccess_Url - Fatal编程技术网

如何检查URL以在.htaccess上包含特殊字符

如何检查URL以在.htaccess上包含特殊字符,.htaccess,url,.htaccess,Url,我需要将包含/../../或/../../*字符串匹配的所有URL重定向到带有.htaccess config的403页 例如,当用户类型https://example.com/index.php/../../js/sample.js在浏览器URL上,我需要重定向到403禁止页面,只需https://example.com/js/sample.jsURL有效,我需要阻止访问Js和其他目录和文件,如URL上的。/../ RewriteEngine On RewriteRule ^.*/\.\./

我需要将包含
/../../
/../../*
字符串匹配的所有URL重定向到带有.htaccess config的403页

例如,当用户类型
https://example.com/index.php/../../js/sample.js
在浏览器URL上,我需要重定向到403禁止页面,只需
https://example.com/js/sample.js
URL有效,我需要阻止访问Js和其他目录和文件,如URL上的
。/../

RewriteEngine On
RewriteRule ^.*/\.\./ - [R=403,NC,L]
将匹配

https://example.com/index.php/../js/sample.js
https://example.com/index.php/../../js/sample.js

最后,我用这个规则来实现我的问题答案,如果你有同样的问题,我希望能帮助你:

RewriteCond %{THE_REQUEST} ^.*/\.\./ [NC]
RewriteRule ^ /404.php [L]