简体   繁体   English

如何将请求重定向到我的Apache服务器上的“ www”子域

[英]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.

相关问题 如何让我的 WordPress 网站在成功登录后重定向到子域,它们将重定向回根域 - How can I make my WordPress site redirect to subdomain once successfully login they will redirect back to root domain 我无法将PHP中的文件复制到apache2 Web服务器中/ var / www之外的另一个目录中 - I can not copy a file in PHP to another directory out of /var/www in my apache2 web server 部署在子域中Apache服务器上的CodeIgniter-重定向循环 - CodeIgniter deployed on an Apache server in a subdomain - Redirect Looping 为什么Nginx将所有子域都重定向到非www,我只是将重定向www设置为非www - Why nginx redirect all subdomain to non-www, I just setting redirect www to non-www 我如何设置.htaccess重定向子域到目录 - How can i set .htaccess for redirect subdomain to directory 尝试将没有查询字符串的任何请求重定向到我的域到子域 - Trying to redirect any requests to my domain without query strings to a subdomain 如何在没有http的情况下将用户重定向到PHP中的www域? - How can I redirect a user to a www domain in PHP without the http? 如何在不转到主页的情况下重定向www? - How can I redirect www without moving to the homepage? 我可以将子域重定向到特定网页并使用PHP处理子域值 - Can I redirect a subdomain to a particular webpage and process the subdomain value with PHP 如何将我的WordPress网站重定向到子域? - How to redirect my WordPress website to subdomain?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM