Tarlan Mammadzada
Tarlan Mammadzada

Reputation: 432

.htaccess allow only from Chrome, Opera, Mozilla, Safari, redirect from others

I want to configure redirect if the user doesn't use Chrome, Safari, Opera or Mozilla.

For inverse problem (if I don't want Chrome etc.) there is a solution:

RewriteCond %{HTTP_USER_AGENT} Chrome
RewriteRule ^abcd.html$ chrome.html [NC,L]

RewriteCond %{HTTP_USER_AGENT} Safari
RewriteRule ^abcd.html$ safari.html [NC,L]

Adding ! before doesn't work

Upvotes: 2

Views: 1192

Answers (1)

hjpotter92
hjpotter92

Reputation: 80657

Negation is done using the ! operator. Using the [NC] flag will also discard strings like chrome, chRome etc:

RewriteCond %{HTTP_USER_AGENT} !Chrome [NC]
RewriteRule ^abcd.html$ chrome.html [NC,L]

Upvotes: 2

Related Questions