Forum Moderators: phranque

Message Too Old, No Replies

Redirecting old version to new

php and G

         

rjwmotor

4:55 pm on Jan 18, 2008 (gmt 0)

10+ Year Member



The cart I run currently is a few years out of date. I haven't upgraded to their newest version b/c they changed the way category URL's are displayed. I want to upgrade but am nervous about rankings since these current URL's rank pretty well on G.

The current URL structure is this:
widgets.com/shop.php?crn=89&action=show&show_products_mode=cat_click

The new is:
widgets.com/shop.php?crn=89

The new one looks better but the biggest problem is that even after the upgrade the page is accessible from BOTH URL's

The only reason I'm considering this is that some customers have begun having difficulties with the cart and when I bring these to the manufacturer they just tell me to upgrade.

Here's the questions:
I have over 140 different categories and would have to do a 301 redirect to the new URL's right?

What kind of damage/loss of traffic can I expect and how long for new URL's to rank?(mainly concerned about Goog)

Is there an easy way to code this redirect without adding code for each individual URL?

Answers are appreciated!

jdMorgan

2:28 am on Jan 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> I have over 140 different categories and would have to do a 301 redirect to the new URLs right?
You should, in order to avoid duplicate-content problems.

> What kind of damage/loss of traffic can I expect and how long for new URLs to rank? (mainly concerned about Google)
Some report no problems at all, while others report poor ranking for months.

> Is there an easy way to code this redirect without adding code for each individual URL?
Assuming you're on Apache and can use mod_rewrite, redirecting as you describe requires only one two-line rule:


RewriteCond %{QUERY_STRING} ^crn=([^&]+)&action=show&show_products_mode=cat_click$
RewriteRule ^shop\.php$ http://example.com/shop.php?crn=%1 [R=301,L]

This will redirect any crn, as long as the query otherwise matches the pattern exactly.

(I assume you have other rules already working; I did not show the "setup" directives for mod_rewrite.)

That's the short-term fix. For the long term, consider designing your own URL structure (Search-engine-friendly URLs) and then rewriting those friendly URLs, when requested by clients, to the form needed by shop.php. This may help your pages' rankings, and reduce the chance that you'll ever have to change your URLs again.

Jim

rjwmotor

3:42 pm on Jan 21, 2008 (gmt 0)

10+ Year Member



This worked great, thank you.
I have another site that this cart runs on and applied it there.

I haven't upgraded the cart on my main site yet out of fear.

I've always wanted to have the old URL's rewritten to "SE friendly" URL's but haven't had the guts to do it for fear of losing ALL rankings. The pages in G(category and product) rank pretty well even with those URL's and I believe "if it isn't broke, don't fix it".

I have always wondered how much better they could rank though...

rjwmotor

9:07 pm on Feb 1, 2008 (gmt 0)

10+ Year Member



I have another question regarding rewrites.
The cart I run is php as shown in the above example. The category pages end in "shop.php?crn=12". When the page is viewed the product links appear as this: "shop.php?crn=12&rn=971&action=show_detail".

If I were to do a rewrite I could wind up with something like this
"shop/12/" for category pages and "shop/12/971.html" for product pages, right?

Now, If I were to do this would the product links appearing in the category pages have the newly constructed url's?

These would all be created on the fly just like a php page, right?

I'm so confused on rewrites and have read so much about them and redirects that I'm not sure what I'm doing..

jdMorgan

5:53 am on Mar 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Mod_rewrite cannot change your URLs, which are defined by the links on your pages. All it can do is redirect one URL to another URL, or change the filepath used to serve content when a URL is requested from your server. As demonstrated above, it can also re-arrange or do simple transformations on the query strings passed to those files.

So, in order to achieve "friendly" URLs, the script used to generate URLs (as links on your pages) must be modified to use friendly URLs in the links on your pages (some scripts have "SEF" plug-ins available to do this). Once your pages are publishing friendly URLs, then you can use mod_rewrite to "steer" requests for the new friendly URLs to the proper script file(s), and with the proper query string parameters.

It helps a lot to keep in mind that URLs are defined on and by Web pages, and filenames are defined by server file naming. URLs have meaning on the Web side, but not inside the server.

Filenames are defined when you create a file on the server. Filenames have meaning inside the server, but not on the Web.

The magical agent that converts URLs to filenames is called a "server". :)

So, if you change the URLs (making them "friendly") but you don't change the script filenames correspondingly, then something must be used to "re-connect" the new friendly URLs to the existing script filenames. That "something" is usually mod_rewrite.

Since you cannot rename your script to a friendly "static" filename (note that you'd need one copy of the script for each friendly URL!), you *must* use some server-side function to "re-connect" the new URLs to the script(s). This further demonstrates the difference between a URL-path and a filepath.

So there are three steps. In logical order -- but not implementation order, they are:
1) Change your script to produce friendly URLs (or use an available "plug-in").
2) Rewrite requests for the new friendly URLs back to the script filepath with proper query parameters.
3) Optionally, redirect direct client requests for the "old unfriendly" URLs to the new friendly URLs. This can speed up re-indexing and help to get the old unfriendly URLs removed from search engine results.

Mod_rewrite can be used for steps 2 and 3.

I showed the steps above in the easiest order for explanation; To actually implement this, you'd want do the above steps in this order: 2, 1, and then --optionally-- step 3

Jim

wyattea

8:18 pm on May 6, 2008 (gmt 0)

10+ Year Member



I'm in a similar boat - I have an old site (7 years) and I'm upgrading the cart. It's not possible to match the urls but the new urls are also seo-friendly already. My old url would be:

/gift-delivery-in-canada/gift-baskets-chocolatechest.asp

while the new url would be

/gift/gift-baskets-chocolate-chest-004400.php

I can't automate it because another url might be

/mothers-day-gift-canada/gift-basket-mommylove.asp

The directory names for every category is different and the file url also.

The question is...how many redirects can I put in before the htaccess file gets too 'bloated'? I have 300-500 urls to redirect. Many of my old pages bring in traffic so I'd like to redirect most of them if possible.

Regards,

James...

wyattea

8:25 pm on May 6, 2008 (gmt 0)

10+ Year Member



btw, i also plan to upload sitemaps to google/yahoo/msn to speed things up.

g1smd

6:59 pm on May 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




*** I can't automate it ***

Yes you can. You rewrite the URL request to one internal script file, with the requested URL appended as a paramerer.

The script then looks that up in a database to return the correct content, or the URL to be returned as a redirect.

wyattea

7:07 pm on May 8, 2008 (gmt 0)

10+ Year Member



When I say I can't automate, what I mean is there is NO pattern to how the old filenames are. my baby gift basket category might use 3 different prefixes (e.g. gift-baskets-canada-[name].asp or baby_gift_canada_[name].asp). There is a pattern actually, completely random :) But do you mean that the URL that is used to visit my site is used in the htaccess file dynamically and then rewritten on the fly? that's far beyond my scope, got any pointers? My cart already uses htaccess to create seo-friendly urls.

Regards,

James...

g1smd

9:38 pm on May 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



No. Nothing directly happens with .htaccess itself, except for one step.

You funnel requests to a script and that script (in conjunction with a database) works out what to do and sends the answer back.

wyattea

10:11 pm on May 8, 2008 (gmt 0)

10+ Year Member



So you have to have a database that has the old url associated with a new url?

g1smd

11:07 pm on May 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yep. That's one way of doing it.

wyattea

11:28 pm on May 8, 2008 (gmt 0)

10+ Year Member



would you happen to have the code to do this? i'm a beginner wrt scripting php...:)