问题
I have this in my .htaccess file:
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} Chrome
RewriteRule ^(.*)$ page.php [NC,L]
Microsoft Edge browser thinks it is Chrome and goes to page.php. Is there any way to avoid Edge from using the Chrome command, so it would not go to page.php?
I have googled so much and I haven't found anything how to direct Edge browser. Any help? Thanks!!
回答1:
The Edge user agent has the word Edge in it, e.g.
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.
It also has the word Chrome in it, so place a rewrite rule for Edge before the one for Chrome.
Note that this was done intentionally (thanks to @Axalix for the link)
Many websites that you visit today will not display well in IE because they are not coded properly and usually display a page like they would in an old browser, even though Internet Explorer 11 supports many of the new web standards. Some pages will display incorrectly in IE while working perfectly fine on other browsers such as Chrome or Firefox.
So you may not want to treat Edge any differently than you do Chrome. Certainly don't just assume it's like a new version of IE.
Is there any way to avoid Edge from using the Chrome command, so it would not go to page.php?
It's not a command, but a user agent header that the browser sends. No, you cannot prevent Edge browsers from sending the user agent that they do.
来源:https://stackoverflow.com/questions/33324947/how-to-separate-microsoft-edge-from-chrome-in-htaccess