删除“www。”从强大的https网址 [英] Remove "www." from url with forceful https
本文介绍了删除“www。”从强大的https网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的.htaccess文件中使用以下内容强制https访问我的网站没有https的任何用户。
I am using the following in my .htaccess file to force https on any user that is visiting my website without https in the url.
但是,如果用户访问 https://www.mysite.co ,我希望能够从请求中删除www。
However, if the user visits https://www.mysite.co, I want to be able to remove the www from the request.
请告诉我在.htaccess文件中需要修改的内容,以便在保持强制https的同时从网址中删除www?
Please can you tell me what I need to modify in my .htaccess file in order to remove the www from the url while maintaining the forceful https?
谢谢,
最多。
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://mysite.co/$1 [R,L]
推荐答案
用2次重写做。
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://mysite.co/$1 [R,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(.*)$ https://mysite.co/$1 [R,L]
这篇关于删除“www。”从强大的https网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文