301 Redirects non-pretty to prettyURL

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
Chris F
Forum Members
Forum Members
Posts: 31
Joined: Wed Jan 28, 2009 3:33 pm

301 Redirects non-pretty to prettyURL

Post 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!
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: 301 Redirects non-pretty to prettyURL

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: 301 Redirects non-pretty to prettyURL

Post by velden »

And if you worry about Google (and others) keep indexing your old ugly urls; implement canonical urls
Chris F
Forum Members
Forum Members
Posts: 31
Joined: Wed Jan 28, 2009 3:33 pm

Re: 301 Redirects non-pretty to prettyURL

Post 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.
Chris F
Forum Members
Forum Members
Posts: 31
Joined: Wed Jan 28, 2009 3:33 pm

Re: 301 Redirects non-pretty to prettyURL

Post 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!
Locked

Return to “CMSMS Core”