繁体   English   中英

无法使用.htaccess重定向到新网址

[英]Cannot redirect to new url using .htaccess

我有一个html网页,并且在网站徽标上,我将徽标URL写为

example.com ,我现在想将所有对example.com请求重定向到http://www.example.com

到目前为止,这是我的.htaccess

ErrorDocument 404 http://www.example.com/404.html 
 Redirect /index.html http://www.example.com

 RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule (.*)$ http://www.example.com/$1 [R=301,L]

example.com未重定向到http://www.example.com

您需要在.htaccess使用以下内容:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

在测试之前,请确保清除缓存。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM