not able to forbidden url | Community
Skip to main content
Level 2
October 27, 2023
Solved

not able to forbidden url

  • October 27, 2023
  • 2 replies
  • 584 views

we have to forbidden certain url based on condition.
for example if url contains /us/en/xyz/
and doesnot have query param view=true we have to forbidden the url.

RewriteCond %{QUERY_STRING} !view=true
RewriteCond %{REQUEST_URI} ^.*/us/en/xyz/.*
RewriteRule .* - [F]

but this is not working.
Can you please suggest the solution for this.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Mahedi_Sabuj

I have tested the same configuration on my local dispatcher, and it's working as intended. If you want to make the URL matching case-insensitive, be sure to add [NC] after the RewriteCond rules. Also, confirm that the URL is a child of /us/en/xyz/ and not the /us/en/xyz.html itself. 

RewriteCond %{QUERY_STRING} !view=true [NC] RewriteCond %{REQUEST_URI} ^.*/us/en/xyz/.* [NC] RewriteRule .* - [F]

Additionally, remember that the order of RewriteRules is crucial. Ensure that there are no prior rewrite rules that might be executed before this one, potentially affecting its behavior. If you could share the URL you've tried, we can provide more specific assistance.

 

 

2 replies

Mahedi_Sabuj
Community Advisor
Mahedi_SabujCommunity AdvisorAccepted solution
Community Advisor
October 27, 2023

I have tested the same configuration on my local dispatcher, and it's working as intended. If you want to make the URL matching case-insensitive, be sure to add [NC] after the RewriteCond rules. Also, confirm that the URL is a child of /us/en/xyz/ and not the /us/en/xyz.html itself. 

RewriteCond %{QUERY_STRING} !view=true [NC] RewriteCond %{REQUEST_URI} ^.*/us/en/xyz/.* [NC] RewriteRule .* - [F]

Additionally, remember that the order of RewriteRules is crucial. Ensure that there are no prior rewrite rules that might be executed before this one, potentially affecting its behavior. If you could share the URL you've tried, we can provide more specific assistance.

 

 

Mahedi Sabuj