Redirect / htaccess question


(Jason Bostick) #1

I know there are lots of .htaccess posts about redirecting, but I just want to confirm my approach before I go any further.

I am helping someone do a re-branding of their business and am moving their redesigned site to a new URL. They’re with GoDaddy and GoDaddy has a simple domain forwarding option in their domain settings. Things are generally working as expected, however, I think the old site has an expired SSL and there are some google search links that have ‘https’ in the address and when you click those, the redirect isn’t kicking in. Change the ‘https’ to ‘http’ ion the URL and it redirects fine.

So, I guess my questions are:

  1. I am presuming that I should remove the ‘forwarding’ settings and do things via htaccess?

  2. If so, would I force http first, then redirect to the new domain?

  3. If that is also correct, this is the code I have for forcing http:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example.com$ [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

  4. And then this is what I have for the redirect (I want all sub files/folders to just go to the main domain, I don’t need to match any files/folders)

RewriteEngine On
RewriteRule ^(.*)$ http://newdomain.com/ [R=301]

Do I have (any of) that correct? Is the order of the redirect important?


(Doug Bennett) #2

Not sure if I understand. Is the new site SSL(https)? I think if you redirect to HTTP from HTTPS the browser will give you a security warning. If the new site has SSL then I would try:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^oldexample.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.oldexample.com [NC]
RewriteRule ^(.*)$ https://www.newexample.com [R=301,L]

This should redirect all www and non-www from the old domain to the new domain(homepage) with https.
I always recommend that you test redirect with a 302 first. Once you’re sure you are working okay for pages (including subpages). then change to a 301. RC 301’s can get cached permanently (or a very long time).


(Jason Bostick) #3

No, the new site isn’t SSL so that could be the issue - in the bottom of the browser, I can see it doing the ‘Performing a TLS handhake’ message and then it just doesn’t load (nor does it change anything in the URL)

I should probably first get SSL setup on the new site anyway though.


(system) #4

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.