[英]How can I redirect the requests to 'www' subdomain on my apache server
I want to redirect a request on my apache server at ' http://example.com ' to ' http://www.example.com ' . 我想将我的apache服务器上位于http://example.com的请求重定向到http://www.example.com 。 I have added as alias but it doesn't work .
我已经添加了别名,但是没有用 。 Please guide me.
请指导我。
You can do the redirect by adding .htaccess file in your root directory with this content: 您可以通过在根目录中添加具有以下内容的.htaccess文件来进行重定向:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
This will force redirect all requests to www. 这将强制将所有请求重定向到www。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.