[英]redirect domain.com to www.domain.com with htaccess
How to redirect an 'empty' subdomain http://domain.com to http://www.domain.com using htaccess rewrite engine. 如何使用htaccess重写引擎将“空”子域http://domain.com重定向到http://www.domain.com 。 It has to be a 301 permanent redirect and convey the rest of the url and query string.
它必须是301永久重定向,并传达其余的url和查询字符串。
Try putting these rules in the htaccess file in your document root: 尝试将这些规则放在文档根目录的htaccess文件中:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
The query string gets automatically appended. 查询字符串将自动附加。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.