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

时间:2018-11-05 12:18:06

标签: .htaccess url

我需要使用.htaccess配置将所有包含/..//../../*字符串匹配项的URL重定向到403页面。

例如,当用户在浏览器URL上输入https://example.com/index.php/../../js/sample.js时,我需要重定向到403 Forbidden页面,而仅https://example.com/js/sample.js URL有效,我需要防止访问Js和其他目录和文件,例如{{ 1}}。

2 个答案:

答案 0 :(得分:1)

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

将匹配

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

答案 1 :(得分:0)

最后,我使用此规则来解答我的问题,如果您有相同的问题,希望对您有所帮助:

var images = [UIImage]()

cell.imageView?.image = images[indexPath.row]
cell.openCamera.tag = indexPath.row