Page 1 of 1

301 Redirects non-pretty to prettyURL

Posted: Fri Mar 17, 2017 2:32 pm
by Chris F
I recently changed my website from 1.0 to 2.0 CMSMS, and am now using PrettyURL. I have been unable to get any 301 redirects to work.

Tried the instructions here: https://www.cmscanbesimple.org/blog/red ... ade-simple

and none of those seem to work.

The old URLs index.php?page=pagename just go to the 404 page, no redirect. Not sure what I'm missing here.

Standard 301 redirects do not work either.

I have the redirects placed directly above the line "# Rewrites urls in the form of /parent/child/grandchild..."

I've tried varying formats, such as:

RewriteRule ^class-levels$ http://www.houstonswimclub.com/about [R=301,L]
RewriteRule ^index.php?page=class-levels$ http://www.houstonswimclub.com/about [R=301,L]

Neither have any effect. Any help is most appreciated!

Re: 301 Redirects non-pretty to prettyURL

Posted: Fri Mar 17, 2017 3:59 pm
by calguy1000
In CMSMS the 'ugly' URL's should always work. This is what CMSMS understands and uses internally.

i.e: <site>/index.php?page=something
so should <site>/index.php?page=blah/blah/something

The 'page' string is determined by the 'query_var' config variable, and rarely changes. If you have it specified in your config.php you can probably remove it.

You should also remove your .htaccess temporarily to make sure that they do work as intended.

Now. Pretty URL's:

The whole goal of pretty URL's is to reformat a request of the format <site>/blah/blah/something into something that CMSMS can understand i.e: <site>/index.php?page=blah/blah/something.

That's what the sample htaccess file we distribute does.

Now 301 Redirects:
These are to tell the browser that a page has been moved permanently to a new location. But... note above that the <site>/index.php?page=blah/blah/something URL's are used internally by CMSMS.

So in your rewrite chain you must, at the end reformat everything to the ugly format anyways.

And if you look at the actual manual for RewriteRule and the attributes... you would realize that [R=301,L] will stop any further rewriting of that URL.

Personally, I would not bother trying to rewrite 'ugly' urls into their pretty form. I would rewrite the ugly urls ONLY if the end page alias changed. Because otherwise, the page hasn't really moved... it just has another way to access it.

Re: 301 Redirects non-pretty to prettyURL

Posted: Fri Mar 17, 2017 6:21 pm
by velden
And if you worry about Google (and others) keep indexing your old ugly urls; implement canonical urls

Re: 301 Redirects non-pretty to prettyURL

Posted: Mon Mar 20, 2017 2:48 pm
by Chris F
I'm not concerned with Google indexing the non-pretty URLs, as they still go to the same page as the prettyURL. I just need to reroute old links that don't exist anymore. Example, index.php?page=class-levels needs to go to index.php?page=about because the 'class-levels' page no longer exist.

Thanks for your help! I've tried utilizing the information you've given me but unfortunately I'm not comprehending it properly. I'm sure this is something rather simple that I simply am not understanding.

I've tried rewriting the redirects with the non-pretty format with no luck.

Re: 301 Redirects non-pretty to prettyURL

Posted: Mon Mar 20, 2017 3:30 pm
by Chris F
Solved by putting directly under RewriteEngineon

RewriteCond %{QUERY_STRING} ^.*page=class-levels.*$
RewriteRule ^index http://www.houstonswimclub.com/about? [R=301,L]

for each broken link.

Thanks again for all your help!