NameSilo

htaccess - direct all traffic to https://www. ?

Spaceship Spaceship
Watch
Impact
24
Hi,

I need to route all domain traffic to https://www.domain.tld

I'm doing this now with htaccess by redirecting traffic on port 80 and it works pretty well but it does not work when https://domain.tld is entered in the browser.

Here's my current htaccess structure:

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.domain.tld/$1 [L,R=301]

Your input is appreciated!
 
1
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
1st solution:

you need to change the https document root path to a different folder than the http folder one.
example:
http://www.bla.bala | /public_html
https://www.bla.bla | /public_html/secure
Then place the .htaccess file in /public_html only

Otherwise, you'll got an undless loop

2nd solution:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

3rd solution:

Using php
PHP:
<?
if($_SERVER['SERVER_PORT']==80)
{
  // redirect it
   header("location:https://bla.bla");
}
else
{
 // do nothing
}
?>
 
Last edited:
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back