简体   繁体   English

.htaccess将子域重定向到ssl网站

[英].htaccess redirect subdomain to ssl site

I want to let my site http://subdomain.domain.com redirect to another external SSL-encrypted domain https://subdomain.external.com , while keeping the original address in the browsing bar. 我想让我的网站http://subdomain.domain.com重定向到另一个外部SSL加密的域https://subdomain.external.com ,同时将原始地址保留在浏览栏中。 As far as I know, it is possible with CNAME to do this very easily, but the problem is that it redirects to the external link without SSL encryption. 据我所知,使用CNAME可以很容易地做到这一点,但是问题是它无需SSL加密即可重定向到外部链接。

I have been told that this can be done with .htaccess file, which right now has the following contents: 有人告诉我可以使用.htaccess文件完成此操作,该文件现在具有以下内容:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Can you help me know how should I modify the .htaccess file to meet my requirement? 您能帮我知道如何修改.htaccess文件以满足我的要求吗? Thank you very much! 非常感谢你!

Juan 胡安

If you want to do it with PHP: 如果要使用PHP:

$redirect = "https://www.ssl.com".$_SERVER['REQUEST_URI'];
header("Location: $redirect");
exit;

Then you have to route all requests to this PHP file via .htaccess: 然后,您必须通过.htaccess将所有请求路由到此PHP文件:

RewriteEngine on
RewriteRule ^([^.]+)$ index.php [QSA]

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

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