Rommeo Posted December 9, 2022 Share Posted December 9, 2022 Hello, For a project integration I need to give access only to "Test-Robot/2022v11" I was using this code when the test robot's name was just "robot" and it was working fine; RewriteCond %{HTTP_USER_AGENT} !=robot RewriteRule .* - [F,L] This also did not work when the name changed into "Test-Robot" (I guess it's because of the hypen that needs to be escaped?) RewriteCond %{HTTP_USER_AGENT} !=Test-Robot RewriteRule .* - [F,L] Now robot's name is "Test-Robot/2022v11" and I need to write a rule for "starting with Test-Robot" (since the rest "/2022v11" will change), how can I write it? I tried this and no success; RewriteCond %{HTTP_USER_AGENT} !^Test\-Robot/* RewriteRule .* - [F,L] Thank you in advance. Quote Link to comment https://forums.phpfreaks.com/topic/315630-rewritecond-for-starting-with-case/ Share on other sites More sharing options...
requinix Posted December 9, 2022 Share Posted December 9, 2022 Are you sure the user agent really starts with Test-Robot? Nothing else in there? The hyphen doesn't need to be escaped (it's not a special character) and /* means "zero or more /". You can put it in quotes just in case. RewriteCond %{HTTP_USER_AGENT} "!^Test-Robot/" Quote Link to comment https://forums.phpfreaks.com/topic/315630-rewritecond-for-starting-with-case/#findComment-1603392 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.