Welcome to WebmasterWorld Guest from 54.166.102.61

Forum Moderators: Ocean10000 & incrediBILL & phranque

Page by page redirect with query strings

   
7:54 am on Mar 26, 2012 (gmt 0)

5+ Year Member



so friends, here is the situation.

One of our clients have recently moved over to Magento which has changed all the previous URLs

The previous URLs were like

example.com/index.php?cName=blue-widgets

and some with cpath, like

example.com/index.php?cPath=20

Now I need to redirect all these URLs to their respective new ones, like

example.com/blue-widgets.html

So how do I go about setting these up?

Previously I had worked on setting up redirects matching all URLs with query strings and redirecting them to a specific page but have never worked on setting up page by page redirects with query strings

Totally lost here...need help

Thanks
8:03 am on Mar 26, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



You could add hundreds of rules to your .htaccess file, one for each URL or group of URLs, but it would be difficult to maintain as well as being very inefficient.

There's a simpler alternative. Rewrite (that's rewrite, not redirect) those requests to a special PHP script that then either looks in an array or in a database for the matching new URL. The PHP script then sends the 301 HEADER and the new location.

This rewrite will use a RewriteRule and be located after the rules which block malicious access and before your canonicalisation redirects.

You have to use a PHP script looking the new URL up because there is no way for mod_rewrite to "know" that ?cpath=20 on the old site matches /purple-widgets/ on the new site.

If you can, use extensionless URLs on your new site. It will make the pattern matching a whole lot easier. There is no need for the .php or .html suffix to appear in your new URLs.
10:38 am on Mar 26, 2012 (gmt 0)

WebmasterWorld Administrator incredibill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



If I understand the problem correctly, this thread may help:
[webmasterworld.com...]
6:51 pm on Apr 3, 2012 (gmt 0)

5+ Year Member



incrediBILL - that thread was a life saver

Thanks a TON!
 

Featured Threads

Hot Threads This Week

Hot Threads This Month