从www重定向。到根域(不含www。)
问题描述:
你如何强制根域使用?我想知道如何做到这一点的从www重定向。到根域(不含www。)
html, php, Javascript, .htaccess,jQuery, ajax.
我知道元刷新
如下所示:
<meta http-equiv="refresh" content="0; url=http://example.com/" />
在这里,我知道这太:
<body onload="window.location.href = 'your URL';"></body>
以及:Php
<?php header('Location: https://example.com'); ?>
但这些工作都不符合我的要求。 多种方法会很好!
答
确保您的htaccess重写正在工作。
使用此对您的htaccess
RewriteEngine On
RewriteBase/
Rewritecond %{HTTP_HOST} ^www\.yoursite\.com$ [NC]
RewriteRule ^(.*)$ https://yoursite.com/$1 [R=301,L]
你尝试搜索? https://*.com/a/1270281/6468413 – JapanGuy
这在你的服务器配置,看到你正在使用的文档 – Kai
@JapanGuy没有工作 – antimalwareprogram