Full Domain Redirect with Regex

#76903
  • Resolved Katie
    Rank Math free

    I recently changed the domain of my site, and want all pages with the previous domain to redirect to the new domain. File structure is the same, so expect all redirects to be 1:1, replacing the domain.

    Old url: tipsychocochip.com
    New url: bestwithchocolate.com

    Expect:
    tipsychocochip.com/cookie-dough-icing –> bestwithchocolate.com/cookie-dough-icing

    Using a different plugin I used the syntax
    Source URL: http://tipsychocochip.com/(.*)
    Destination URL: http://bestwithchocolate.com/$1

    Is there an equivalent structure or format I should be doing here to achieve the desired functionality in Rank Math?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Alberto
    Rank Math business

    Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    My recommendation would be using .htaccess for this kind of redirection, since they are better running directly in your .htacces file.

    The usual redirection setup for this would be this one:

    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^OLDDOMAIN\.com$ [NC]
    RewriteRule ^(.*)$ https://NEWDOMAIN.com [R=301,L]

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Katie
    Rank Math free

    Thank you for your quick reply! I ended up with this snippet in my .htaccess file in order to match ‘www’ and non ‘www’ links, as well as contain the directory structure for the redirect.

    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^tipsychocochip.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.tipsychocochip.com$
    RewriteRule (.*)$ http://www.bestwithchocolate.com/$1 [R=301,L]

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘Full Domain Redirect with Regex’ is closed to new replies.