• I have recently changed the domain URL on a website and taken away a root level folder, and I am having problems getting the redirects to work correctly.

    The domain to domain redirection works fine – ie, https://bangkoktravelthailand.com redirects with 301 to https://traveltipsthailand.com. But links to deep URLs in the old domain still load the page with the old domain URL, eg try https://bangkoktravelthailand.com/thailand/bangkok/yaowarat/

    If all transforms were working correctly it would redirect to: https://traveltipsthailand.com/bangkok/yaowarat/ (as the “/thailand/” folder is no longer used on the site.

    There are two htaccess rules in place which should be transforming this url:

    RewriteCond %{HTTP_HOST} ^bangkoktravelthailand\.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.bangkoktravelthailand\.com$
    RewriteRule ^/?$ “http\:\/\/traveltipsthailand\.com” [R=301,L]

    and

    RewriteRule ^thailand/(.*)$ https://traveltipsthailand.com/$1 [R=301,L]

    The second rewrite rule does work to remove “/thailand/” from URL strings if the domain in the URL is “traveltipsthailand.com”, but not if it’s “bangkoktravelthailand.com”. Does that make sense?

    I also tried a variation of the first rewrite rule as:
    RewriteRule ^(.*)$ https://traveltipsthailand.com/$1 [R=301,L]
    but that didn’t work either.

    Can anyone suggest a rule that will work for me? I’ve run out of ideas and google searches to try.

    Tony

  • The topic ‘Fixing redirects in htaccess after domain change’ is closed to new replies.