https to https URL redirection
Hi All,
I have been an end user for Cpanel, now at the pointy end to get stuff done. Learning a lot from the forums (thanks).
Question:
I have a simple question on URL redirection. I need all sub domains without www which needs to be redirected for HTTPS only eg. when I goto https://a.com/abc/xyz.html, it should go to
https://1.b.com/abc/xyz.html. This needs to be a temporary link only.
when I goto
Things you need to know:
1. I own . This is hosted on a different server apart from a.com
3. I have a reseller account only, so NO root access to server
4. Underlying OS is CentOS I believe with litespeed & cpanel
What I have tried so far:
I tried a few options does not work. Tried via CPANEL redirection & .htaccess. This is the latest .htaccess entry I tried, still NO luck
RewriteCond %{HTTP_HOST} ^a\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.a\.com$
RewriteRule ^(.*)$ "https\:\/\/1\.b\.com\/$1" [R=302,L]
Thanks in advance.
triaxial
-
Hello :) You will often see more feedback on custom Mod_Rewrite rules for redirection on websites such as StackOverflow. Here's one example I found: Htaccess url redirect only https urls Thank you. 0 -
Tried that it does not work.. The word press one exists, so Option 1 tried: # BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress RewriteEngine On RewriteCond %{HTTPS} ^a.com$ RewriteRule ^(.*)$ "https\:\/\/1\.b\.com\/$1" [R=301,L] option 2 tried: # BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] RewriteCond %{HTTPS} ^a.com$ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ "https\:\/\/1\.b\.com\/$1" [R=301,L] # END WordPress 0 -
You may receive more user-feedback for custom Mod_Rewrite rules on forums such as StackOverflow. Please update us on your findings after creating a new post there if the existing posts are unhelpful. Thank you. 0 -
So, I only noticed the thread was so old after I wrote this... I kinda really just wanted to put up something better so I went ahead =) Here is what I'd have tried: # Maybe uncomment engine and base, depends where you place this in the file # only need to turn on the engine once... #RewriteEngine On #RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)\ HTTP/ [NC] # Uncomment line below if you want this redirect to only apply to https requests #RewriteCond %{HTTPS} =on [NC] RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTP_HOST} a\.com$ [NC] RewriteRule ^ 0 -
Hello, Thank you for the update. Could you confirm if the updated rules work as expected? Thank you. 0
Please sign in to leave a comment.
Comments
5 comments