301 redirect. Could you help me?

General questions about CMSimple
Post Reply
sareide
Posts: 21
Joined: Sat Apr 07, 2012 1:26 pm

301 redirect. Could you help me?

Post by sareide » Sat May 19, 2012 10:44 am

Hi
I've reorganized my site so I have changed its structure. I've also used the htaccess with the form:
ErrorDocument 400 http://www.yyyyy.com/?ERRORE
ErrorDocument 401 http://www.yyyyy.com/?ERRORE
ErrorDocument 403 http://www.yyyyy.com/?ERRORE
ErrorDocument 404 http://www.yyyyy.com/?ERRORE
ErrorDocument 500 http://www.yyyyy.com/?ERRORE
in order to send the missing request page ton an cmsimple error page (hidden) called ERROR.

My problem is that I've also changed the separator from : to /; thats is, previously the page had a link ( from google) http://www.yyyyy.com/?level1:level2 and now http://www.yyyyy.com/?level/level2.

So I need to redirect users coming from external sites (google) to the right page. But As you could read in this tutorial (http://www.tamingthebeast.net/articles3 ... direct.htm) you must use the RewriteEngine on block.

Does someone has used this trick? could you help me?
thanks in advance
sareide

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: 301 redirect. Could you help me?

Post by cmb » Mon May 21, 2012 9:16 pm

Hi sareide,

I'm not really experienced regarding mod_rewrite, so the following is probably not the most elegant solution, but it should work (at least I hope so -- I've just made some quick tests) for menu_levels<=3. Just put a .htaccess to the CMSimple root directory:

Code: Select all

RewriteEngine on
RewriteBase /CMSimple_XH_153/
RewriteCond %{QUERY_STRING} (.*):(.*):(.*)
RewriteRule .* ?%1/%2/%3 [NE,L,R=301]
RewriteCond %{QUERY_STRING} (.*):(.*)
RewriteRule .* ?%1/%2 [NE,L,R=301]
If you have CMSimple directly in the web (HTTP) root, just remove the 2nd line. Otherwise change "CMSimple_XH_153" to the path to the root directory.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply