homepage Welcome to WebmasterWorld Guest from 54.197.171.109
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Page by page redirect with query strings
pro_seo




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

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

 

g1smd




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

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.

incrediBILL




msg:4433472
 10:38 am on Mar 26, 2012 (gmt 0)

If I understand the problem correctly, this thread may help:
[webmasterworld.com...]

pro_seo




msg:4436817
 6:51 pm on Apr 3, 2012 (gmt 0)

incrediBILL - that thread was a life saver

Thanks a TON!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved