Redirect (re)moved pages in CMS Made Simple

  Previous article

Redirect (re)moved pages in CMS Made Simple

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.1.6
  Last updated: 09-03-2017
  Comments: 0

After several years maintaining a website you have added a lot of pages, news and blog articles, but you have also removed or moved some to another place at the site. You don't want visitors to get an error 404 page, so you want to redirect them to the current spot.

Not that I am an expert in rewrite rules, but the examples below work for my websites :) I will add more later...

  Internal Redirects

The most common method is:

Redirect 301 /index.php?page=something-old http://www.website.com/index.php?page=something-new

But when you use Pretty URLs at your CMS Made Simple™ website 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$ http://www.website.com/new/path/to/something [R=301,L]
RewriteRule ^something$ http://www.website.com/something [R=301,L]
RewriteRule ^something/$ http://www.website.com/something/ [R=301,L]
RewriteRule something.html$ http://www.website.com/something [R=301,L]

In the default .htaccess file (supplied in the CMSMS™ 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$ http://www.website.com/new/path/to/something [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

A2 Webhosting CMS Made Simple

  Internal Page Links

You can also use the CMSMS core Internal Page Link to redirect moved pages, or use for creating short URLs:

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

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.

A2 Webhosting CMS Made Simple

  External Redirects

You have a popular blog and want to change the domain name. This way all incoming blog links are redirected to the new domain:

RewriteRule ^blog(/?|/.+)$ http://www.newwebsite.com/blog$1 [R=301,L]

www.website.com/blog/foo will be redirected to www.newwebsite.com/blog/foo
www.website.com/blog/bar will be redirected to www.newwebsite.com/blog/bar


A2 Webhosting CMS Made Simple

  Comments

  Click here to leave a comment






This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)
  « Enter the CAPTCHA code (lower case)

Your IP address will be stored on submit. I reserve the right to change or delete your response without notice!
In case of abuse your IP address will be blocked!


Can I have your attention for a moment?

Did this tutorial help you solving a problem at your (clients) website and it saved you many hours of work? Great!!
Consider buying Rolf a cup of coffee in return! [ Click here ]

CMS Made Simple 2.1.6 - Tutorials, tips and tricks - CMSMS 2.1.6

Redirect (re)moved pages in CMS Made Simple

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.1.6
  Last updated: 09-03-2017
  Comments: 0

A2 Webhosting CMS Made Simple