301 redirect help

AidanLCFC

Affiliate Guard Dog Member
Joined
Mar 8, 2012
Messages
750
Reaction score
451
You might find this unbelievable and laughable but I need to reach out for some help. How do I write a 301 redirect code please? I've got an old site that the ssl had expired and just purchased a new one but need to set the redirect. So say I want every version redirecting to hxxps://www.ImADivvy.com what is the exact text I need to add to htaccess please? so hxxp//ImADivvy.com, hxxp://www.ImADivvy.com all redirect to the correct domain?

cheers
 

Murphy

New Member
Joined
Apr 18, 2020
Messages
6
Reaction score
0
Hi Aidan.
Probably you have an option in your domain's cPanel to renew SSL certificates. If you do so, then your service provider will automatically use hxxps by default. Also, maybe there is a manual option in your cPanel to redirect everything to hxxps. But, if you can not find these, then copying the following five lines in your .htaccess will solve your problem.
 

Murphy

New Member
Joined
Apr 18, 2020
Messages
6
Reaction score
0
Sorry, I can not show you. I tried to type in, but the AFG system popped up a message, that I can not share links, however, it wasn't a link. Then I tried upload an image, but the same message...
 

Murphy

New Member
Joined
Apr 18, 2020
Messages
6
Reaction score
0
:) Problem solved. Put the three parts of the link together. On the resulting link, you will find the necessary code.
 

BetOnlineUK

Affiliate Guard Dog Member
Joined
Jun 8, 2016
Messages
432
Reaction score
203
That is a domain name and a half mate. Could be used as a personal website for the prime minister if he wants it ;)
 

preditor

Affiliate Guard Dog Member
Joined
Sep 14, 2010
Messages
453
Reaction score
303
Try this, i use it on one of my sites and works:

Code:
# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

http: + http://www. + https:
301 to
https://www.

Edited - Thanks for pointing out the code in posts Aussie!
 
Last edited:

baldidiot

Affiliate Guard Dog Member
Joined
Feb 23, 2011
Messages
713
Reaction score
218
You're talking about just redirecting http to https for the same domain, right?

Tbh it's so common you can do this directly with a lot of hosts without using htaccess - eg: both cpanel and plesk have options to force ssl.
 

AussieDave

24 years & still going!
Joined
Nov 28, 2013
Messages
5,103
Reaction score
3,607
Just an FYI for those adding code directly to their post(s)... Instead, the code should be enclosed in the following. Using this format, URL's etc aren't converted to active links:

[ code ]

[/ code ]

NB - spaces only added to prevent tags not displaying. If your using this format, you would not use spaces ;)

EG - here's an example using the above:

Code:
placing code into this formatted area, will display said coding and not active linking https://www.whateverdomain.com
url isn't converted to a clickable link!
 

AidanLCFC

Affiliate Guard Dog Member
Joined
Mar 8, 2012
Messages
750
Reaction score
451
Try this, i use it on one of my sites and works:

Code:
# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

http: + http://www. + https:
301 to
https://www.

Edited - Thanks for pointing out the code in posts Aussie!
Hi guys, I have another site i'm struggling with, what code would it be so everything redirects to https://non-www?
 
Top