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

£可爱£侵袭症+ 提交于 2019-12-11 00:33:32

问题


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


回答1:


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]


来源:https://stackoverflow.com/questions/39924802/htaccess-allow-only-from-chrome-opera-mozilla-safari-redirect-from-others

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!