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

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Spacemail by SpaceshipSpacemail by Spaceship
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
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back