简体   繁体   English

使用Apache虚拟主机将子域重定向到HTTPS WWW URL

[英]Redirecting Subdomain to HTTPS WWW URL using Apache Virtual Host

I was wondering how do you redirect a subdomain for both HTTP & HTTPS to a specific URL. 我想知道如何将HTTP和HTTPS的子域重定向到特定的URL。

I want it to go from: 我希望它来自:

http://test.example.com to https://www.example.com/test

and

https://test.example/com to https://www.example.com/test

Hope this will help you out, as it is working for me. 希望对您有所帮助,因为它对我有用。

Check this .htaccess code here 在这里检查此.htaccess代码

RewriteEngine on
RewriteCond %{HTTP_HOST} ([a-z]+)\.(example\.com) #checking domain and subdomain
RewriteRule ^(.*)$ https://www.%2/%1 [R=301,L] #redirecting

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

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