skip to Main Content

I have 3 domains, www.1.com (primany), 2.com (addon)and 3.com (addon) hosted at cPanel (Linux) in single account.

I’m planning to redirect only 1.com to https and not to disturb on other 2 domains, but as i add these codes at .htaccess root, all my other domains get redirected to https://1.com as well.

How do i ensure, only 1.com get redirected to https, without getting all other domain directed to https://1.com/

code that i added

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]

2

Answers


  1. Chosen as BEST ANSWER

    Managed to figure out, i've edited the .htaccess at root directory by add these at top:


    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]
    

  2. Using 1.php as the name of the PHP file you want redirected you can write an if condition to check if 1.php was called or some other file.

    RewriteCond %{HTTPS} !=on
    RewriteCond %{REQUEST_URI} 1.php
    ...
    RewriteRule ^(.*)$ https://1.com/$1 [R=301,L]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search