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

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
Watch
Impact
25
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
Close
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
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Search: choose where to search from the All tab
Open the search at the top of any page. On the All tab, the list next to the search box lets you choose where to search: everything, all...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back