When moving a new site live, it’s critical that you have 301 redirects from the old urls to the new ones. 301 redirects help to preserve any SEO you’ve earned on the old site. Here’s how to create a 301 redirect in Modx on Apache2. Let’s say you had www.example123.com/old-directory/ on the old site and now you’d like that page to go to www.example.com/new-page/.

In the site root, open up the .htaccess file and find:

RewriteEngine On
RewriteBase /

Directly under that, you’ll need to add:

RewriteRule ^old-directory http://www.example.com/new-page [R=301,L]

Let’s break down what that means:

RewriteRule: This tells the server to use MOD_REWRITE (an Apache module)

^old-directory: “If the url begins with old-directory then…”

http://www.example.com/new-page: The new location you want to go to (without the ending slash)

[R=301,L]: This is a 301 redirect. Stop processing the page load and rewrite the url.

Leave a Reply

Your email address will not be published. Required fields are marked *