Redirect (re)moved pages

This entry deals with issues which involve knowledge of servers and a strong understanding of htaccess and apache rules. It is provided as a courtesy, but not officially supported by the CMSMS Development Team.

After several years maintaining a website you have added a lot of pages, but have also some removed or moved to another place in the hierarchy of the site. You don't want visitors to get a error 404 page, so you want to redirect them to the current page. The most common method is:

Redirect 301 /index.php?page=something-old

But when you use pretty urls the redirect 301 method in the .htaccess file might fail...

Try to use one of these rewrite rules instead:

RewriteRule ^old/path/to/something.html$ [R=301,L]
RewriteRule ^something$ [R=301,L]
RewriteRule ^something/$ [R=301,L]
RewriteRule something.html$ [R=301,L]

In the default .htaccess file (supplied in the docs folder), add your custom redirect rules above "Rewrites urls in the form of /parent/child/" or they may not work. For example:

RewriteRule ^old/path/to/something.html$ [R=301,L]

# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f

The above examples assume an apache webserver. The file to edit and the syntax will be different for different webservers

   Internal Page Links

You can also use the Internal Page Link to redirect moved pages:

  1. Created a new "Section Header"
    • Set the Title to "Redirects" and Page_Alias to "redirects"
    • Set the Parent to "none", via the pulldown
    • Set the page's Options checkboxes to Active = false and Show In Menu = false
  2. Then for each moved page:
    • Add a new "Internal Page Link"
    • Set the Parent of the new link to "Redirects", via the pulldown
    • Set the Destination Page to the moved page's NEW location, via the pulldown
    • Set the link's Options checkboxes to Active = true and Show In Menu = false
    • Set the Page URL to the moved page's OLD URL
    • Set the link's Page Alias to something unique like "moved-pages-alias"-redirect

One nice thing about this technique is that all these Internal Page Links can be placed under the "Redirects" parent page where they don't clutter up the primary page hierarchy.