如何重定向到具有多个域的https cpanel

问题描述 投票:0回答:2

我有3个域名,www.1.com(primany),2.com(插件)和3.com(插件)托管在cPanel(Linux)的单一帐户。

我打算只将1.com重定向到https,而不是打扰其他2个域,但是当我在.htaccess root添加这些代码时,我的所有其他域也被重定向到https://1.com

我如何确保,只有1.com被重定向到https,而没有将所有其他域定向到https://1.com/

我添加的代码

RewriteOptions inherit

RewriteEngine on
AddHandler application/x-httpd-php56  .php56 .php
RewriteCond %{HTTPS} !=on [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://1.com/$1 [R=301,L]

php apache .htaccess redirect
2个回答
0
投票

使用1.php作为要重定向的PHP文件的名称,您可以编写if条件来检查是否调用了1.php或其他文件。

RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} 1\.php
...
RewriteRule ^(.*)$ https://1.com/$1 [R=301,L]

0
投票

管理好了,我在根目录中编辑了.htaccess,在顶部添加这些:


RewriteOptions inherit    
RewriteEngine on    
AddHandler application/x-httpd-php56  .php56 .php    
RewriteCond %{HTTPS} !=on [NC]    
RewriteCond %{HTTP_HOST} ^1\.com$ [OR]    
RewriteCond %{HTTP_HOST} ^www\.1\.com$    
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$    
RewriteRule ^(.*)$ https://1.com/$1 [R=301,L]
© www.soinside.com 2019 - 2024. All rights reserved.