MENU

Redirect (re)moved pages in CMS Made Simple

  Previous article Next article  

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 web servers

  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.

  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


Buy Me A Coffee


  Comment Form

ReviewManager

Click here to open the form

ReviewManager

  4 Comments

Buy Me A Coffee

CMS Made Simple - Tutorials, Tips and Tricks - CMSMS

Redirect (re)moved pages in CMS Made Simple

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.19
  Last updated: 23-06-2018
  Comments: 4
  http://cms.ms/YBJh


Buy Me A Coffee




Advertisement


Ads help me to help you! Thanks!

Ads help me to help you! Buy products from these advertisers!