Redirect (re)moved pages in CMS Made Simple
Previous article Next articleAfter 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:
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:
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:
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
Comment Form
ReviewManager
ReviewManager
4 Comments
Hi,
Thanks for the post Rolf. I had the same problem as "04-08-2018 Andrew" and this solution works for me "RewriteRule ^old/path/to/something.html$ http://www.website.com/new/path/to/something [R=301,L]".
Hi,
i tried this but it doesn't work for me :
RewriteRule ^old/path/to/something.html$ http://www.website.com/new/path/to/something [R=301,L]
I always get an 404 error page...
Then i tried to create an internal link, but i can't set the url, error message is telling that "?" characters or "=" are not allowed
(example = salons.php?nom=Salons&lng=Fr)
:/
@Andrew
Probably a conflict with some other rewrite rule in your .htaccess file...
Put the lines from the tutorial in the top of your file!
I just rebuild my website https://buispost.eu and made lots of rewrites, I had no issues here.
Grtz. Rolf
In each of your examples I get the following result:
https:/xxx.org/newfilename?page=oldfilename
So it has the new file name correct, but how / why is it adding ?page=oldfilename