Welcome to the Microsoft Q&A Platform. Thank you for reaching out & I hope you are doing well.
I understand that you would like to block users from accessing a page in your site, constoso.com/test.txt
For the context, we can consider your site as www.contoso.com.
I can think of two methods to prevent users from accessing www.contoso.com/test.txt
Method1 : Using URL Rewrite
- This method will not block the requests to www.contoso.com/test.txt , but instead will route all requests to www.contoso.com.
- This is as good as restricting access to this particular page and also have a fallback to home page in case users access www.contoso.com/test.txt by mistake
- Refer:
- Rewrite URL with Azure Application Gateway - How to
- Rewrite HTTP headers and URL with Application Gateway - Pattern Matching and Server variables
- One added advantage here is that you can do this with regular SKU and does not require a WAF SKU
Method2 : Use a Custom Rule
- This is straight forward.
- You use a custom Rule in Azure WAF to create a DENY rule
- Refer
- Custom rules for Web Application Firewall v2 on Azure Application Gateway
- You should use RequestUri as Match Variable and specify it as /test.txt
It must be noted that WAF rules are used to DENY/ALLOW Request based on client properties generally
In case you have a page /test.txt and you do not want users to access this, it is recommended that you must remove this from your site.
Kindly let us know if this helps or you need further assistance on this issue.
Thanks,
Kapil
Please l