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.
Solved! Go to Solution.
Views
Replies
Total Likes
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.
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.
Hi @Sudarshan1992
Rules are fine, you check here https://technicalseo.com/tools/htaccess/?share=ewogICJodGFjY2VzcyI6ICJSZXdyaXRlQ29uZCAle1FVRVJZX1NUU...
As mentioned by @Mahedi_Sabuj , there could be the other rules which are conflicting.
Views
Likes
Replies
Views
Likes
Replies