Looking to transition away from those old dynamic URL’s on your old shopping cart?  Need some help figuring out how to transfer all that link equity you may have built up over the years? Here are four things you can do to transfer link equity from old dynamic looking URL’s to your newer, static looking ones:

1) use some htaccess commands

I see a lot tutorials out on the web that show people how to rewrite dynamic URL’s to static URL’s, which is great, however most tutorials fail to mention that when you rewrite a URL path you aren’t actually telling your web server to 301 redirect the old URL to the new one, which means link equity doesn’t transfer. 

So lets dive right in to fix that problem! If you wanted to 301 redirect:




then you could use these two htaccess lines of code (for apache)

rewriteCond %{query_string} &?search=([^&]+) [NC]
RewriteRule ^(.*)$ /$1/%1? [L,R=301]

How it works: the first of the above two lines of htaccess code looks at the query string (portion of the URL after the "?") and matches URL’s that have the "?search=" character string (all the old search pages) then stores matching characters between the "()" into the %1 variable on the second line.  The second line of code then matches URI’s (anything before the "?" in the URL) then stores matching characters between the "()" in the $1 variable (so it just stores any URI that also meets the first line of codes condition).  Next, the second line of code then redirects to /$1/%1/0  where $1 is the stored URI and %1 is the actual search query stored from the first line of code.  the [L,R=301] lets apache know to apply a 301 redirect.  Note that we aren’t accounting for spaces or plus signs or any other special characters in the query string.  You could take things a step further with this example to remove "+" signs in the query string:

rewriteCond %{query_string} &?search=([^&]+) [NC]
RewriteRule ^(.*)$ /$1/%1/0? [R]
rewriteCond %{request_uri} ([^+].*)+([^+].*) [NC]
RewriteRule ^(.*)$ %1-%2? [L,R=301]

however it creates an additional 301 redirect for every extra special character ("+" in this case) it encounters in which it needs to change to "-" in the URL, so using the exact code above isn’t going to be optimal but should be a starting point for those aggressive developers.

2) Using Drupal’s redirect module or custom build your own

If you’re using the ever so awesome Drupal platform for your website, there is a nice redirect module that lets you create 301 redirects (as well as other types of redirects) individually – this is great for smaller websites or your team can easily redirect the most popular search queries if your site is large (reference your analytics to know which ones to focus on).

As far as creating regular expression rules to catch all cases for larger websites, your team may have to dive in to the redirect module or create your own module.  In fact, creating your own custom module wouldn’t be that difficult: just do a drupal_goto call (specify a 301 redirect) when dynamic pages are requested that have a query string (characters after the "?" in the URL path) that match the start of the php $_SERVER[‘QUERY_STRING’] variable.  Going this route would probably be more flexible than trying to mess with htaccess directive hell.

3) Robots.txt

Disallowing bots from accessing the old search paths is good for preventing duplicate content penalties but won’t replace old with new URL’s in a given engine’s index.  That being said, if you needed to use robots.txt to prevent the search bots from accessing your old pages in conjunction with the canonical URL tag (described below) you could do

Disallow: /*results?search*$

where "results" is the last portion of your URI (part of the URL before the "?") and "search" is the starting characters in the query string (portion of the URL after the "?") that you want to redirect.

I tested the above command on Google’s webmaster central robots.txt checking tool and it appeared to pass without error.

4) canonical URL tag

Another option (as mentioned above point 3) would be to print the relatively new "canonical URL tag" on your old search results pages, Rand has a more detailed description on the tag.

By using the tag you would be telling the engines to give any link equity from the old search results pages to the new one listed in the tag.  By doing this you wouldn’t really remove the old search results from the index right away (until Google decides to do so automatically), but they’d be filtered out and would send a clear signal to Google that you want the new search results pages to take precedence over the old ones.

For example you could print

<link rel="canonical" href="http://www.converanet.com/information-technology/results/myquery/0"/>
in the head tag of

Wrapping up

Ok well that’s it for now.  I have a few other ways to transfer link equity with a 301 redirects tutorial in a previous article, go check that out if you’re in dire need of simple to moderate 301 redirect help.


Your email will not be published. Required fields are marked *

There are no comments yet.

Other posts you will enjoy...

4 Common Email Problems and How to Solve Them
5 Ways People and Organizations are Fighting Fake News
What Impact Can HTTPS Have on Your SEO?
Why You Need a Content Marketing Agency in 2017