Reputation: 640
I need to redirect all URLs that contain /../
or /../../*
string match to 403 page with .htaccess config.
For example when user type https://example.com/index.php/../../js/sample.js
on browser URL, I need to redirect to 403 Forbidden page and just https://example.com/js/sample.js
URL is valid, I need to prevent access Js and other directories and files like ../../
on URL.
Upvotes: 0
Views: 364
Reputation: 640
Finally i use this rule to achieve my question answer, I hope to help you if you have same question:
RewriteCond %{THE_REQUEST} ^.*/\.\./ [NC]
RewriteRule ^ /404.php [L]
Upvotes: 0
Reputation: 19164
RewriteEngine On
RewriteRule ^.*/\.\./ - [R=403,NC,L]
will match
https://example.com/index.php/../js/sample.js
https://example.com/index.php/../../js/sample.js
Upvotes: 1