htaccess 301 rewrite and pretty URLs

I have found a big problem with htaccess and a CMS that I use.

When I enable "pretty URLs", 301 rewriting cannot be used properly.

See my forum posts at

http://forum.cmsmadesimple.org/viewtopic.php?f=28&t=55614&p=257950

http://forum.cmsmadesimple.org/viewtopic.php?f=34&t=55918

 

After each htaccess change, do not forget to do the following: clear CMS cache, clear browser cache, press ctrl+F5, and after page reloads, try your address query again.

 

What works:

See two links above for examples of redirects that work.

For example, a relative path to non—pretty query:

redirect 301 /about-this-website.html http://mkrd.info/?page=about-me

 

What does not work with "redirect 301" method:

redirect 301 /about-this-website.html http://mkrd.info/about-me.html

 

How to get 301 redirect to work:

 

------------------

With about half an hour of tweaking on my second attempt, I got it to work.

To summarize:

Old 301 rewrite rule was something like
redirect 301 /portals/electronics-as-a-hobby/general-and-misc-2.html http://wiki.mkrd.info/Electronics_as_a_Hobby_portal

To convert to a RewriteRule, use a ^ character. I think that this does pattern matching. Do not use opening "/". Add $ at the end of old page URL.

Any one character off will break the rewrite functionality.

RewriteRule ^portals/electronics-as-a-hobby/general-and-misc-2.html$ http://wiki.mkrd.info/Electronics_as_a_Hobby_portal [R=301,L]

Is the code to redirect a .html page that used to be within subfolders (as far as could be seen from outside CMSMS) (or parent pages in CMSMS) /portals and /electronics-as....

-----------------

 

Also, watch out for tiny errors in htaccess formatting, that will bring down your website (search this website for examples of such errors). For example:

SPACE HERE BREAKS SITE

#redirect 301 /Alien Shooter Games Series http://wiki.mkrd.info/Alien_Shooter_Game_Series_Portal

FILETYPE HERE BREAKS SITE

#redirect gone /uploads/publications/Michael's Memory Download - Linux.odt

 



˅˅˅ Additional valuable information is available at one of the links below: ˅˅˅

 

Did you like the article? Let Google Search know by clicking this button: . Please link to content that you find useful on this website on your own website, forum or blog! You can also comment on this page below, or contact me to ask a question or suggest a topic for me to research. There is a user-editable Wiki available on my website, as well as a Forum that you can contribute to. Site Map.

Page last modified 29-Sep-11 20:17:22 EDT
Comments on this page:


Add a comment to this page
Comment Title:
Your Name:
Your Email Address:
Notify me of new comments to this item:
Additional Comments:
This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)