View Full Version : Redirect existing redirects
office7
09-21-2009, 01:36 AM
Some time ago, we moved all of our articles from our catchall /html/ directory to a new /articles/ directory under the root and did a 301 redirect on all the moved article pages.
We are redoing our site structre and are creating a series of subdirectories under the /articles/ directory to further subclassify our articles. The number of article pages is approx 200 on our 400 page website. Should we just add another 200 lines to our .htacces file, adding to the original redirects? That is, for each page, should we have this in our .htaccess:
Redirect permanent /html/articlename.html http://www.oursite.com/articles/articlename.html
Redirect permanent /articles/articlename.html http://www.oursite.com/articles/newdir/articlename.html
There is no simple rule for the redirects, so a RedirectMatch won't work -except maybe a match on the precise article name. (That could cut two lines down to one.) Also, most of the article pages have at least one external inbound link. Most importantly, we don't want to lose our existing link juice. Can we do some kind of match on each article name? Is writing the new 301 redirect lines in our .htaccess the best way to go, or is there a better option?
Thank you in advance for your suggestions.
danlefree
09-21-2009, 05:29 AM
If you are running PHP, this PHP 301 redirect script (http://www.webproworld.com/discussion-forum/89332-how-do-you-redirect-url-0a-splitting-up-html-extension-htm-0al.html#post459022) might come in handy. The script could be extended to search your web root filesystem or a database for URI:redirect comparisons.
But if you can, avoid it.
Personally, I often view, and have experienced a redirected redirect as spam.
Google will surly treat so much redirection as a Spam check Google Guidelines, Google has suggested to do minimal redirection and that too when necessary.
From what I have read, published by Google's Talking Heads, an occasional redirect, for instance, when reorganizing your site, such as you are doing, is acceptable, and wouldn't necessarily be penalized. However, IMO, doing so with 200 pages, would be really pushing the envelope, and might get you entangled in a Google spam filter. I would recommend a different method. I think it's also worth noting that even if you don't experience any filter problems, it's still probable that you'll be losing at least some of your current juice.
danlefree
09-21-2009, 11:41 AM
Note on the redirect script - if a redirect is configured for the original URI and the new URI to redirect, you should only have one redirect per URI (as kgun and Ace mentioned, it is inadvisable to create multiple redirects).
That script shouldn't be the first choice for handling wholesale directory renaming - it's better as a tool for handling one-off changes and URI's which are rarely visited.
If you're moving directories, you'll be served even better by some mod_rewrite directives (assuming an Apache environment).
office7
09-22-2009, 11:26 PM
Thank you for all of your suggestions. I think you have got me on the right track. I checked out mod_rewrite (we are on an Apache box) and have constructed the following to go in the .htaccess in our root directory:
RewriteEngine on
RewriteBase /
RewriteRule ^[(html|articles)]/articlename\.html$ http://www.businessperform.com/articles/newdir/articlename.html [R=301,L]
articlename.html and /newdir/ will be different for each of our articles and the last line is repeated for each articlename.html. I'm hoping this will redirect url requests for articles in our /html/ and our /articles/ directories to the new position in /articles/newdir/
I welcome any comments or suggestions.
Regards, Les
danlefree
09-23-2009, 06:07 AM
RewriteEngine on
RewriteBase /
RewriteRule ^[(html|articles)]/articlename\.html$ http://www.businessperform.com/articles/newdir/articlename.html [R=301,L]
articlename.html and /newdir/ will be different for each of our articles and the last line is repeated for each articlename.html. I'm hoping this will redirect url requests for articles in our /html/ and our /articles/ directories to the new position in /articles/newdir/
The directives which you specified will probably not perform as you would want... try these:
RewriteEngine on
# /html/* and /articles/* => /articles/newdir/*
RewriteCond %{REQUEST_URI} ^/(html|articles)/ [NC]
RewriteRule (html|articles)(.*) http://www.businessperform.com/articles/newdir$2 [R=301,L]
# Host rewrite (non-www => www)
RewriteCond %{HTTP_HOST} !^www\.businessperform\.com [NC]
RewriteRule .? http://www.businessperform.com%{REQUEST_URI} [R=301,L]
angilina
09-23-2009, 05:28 PM
Some time ago, we moved all of our articles from our catchall /html/ directory to a new /articles/ directory under the root and did a 301 redirect on all the moved article pages.
We are redoing our site structre and are creating a series of subdirectories under the /articles/ directory to further subclassify our articles. The number of article pages is approx 200 on our 400 page website. Should we just add another 200 lines to our .htacces file, adding to the original redirects? That is, for each page, should we have this in our .htaccess:
There is no simple rule for the redirects, so a RedirectMatch won't work -except maybe a match on the precise article name. (That could cut two lines down to one.) Also, most of the article pages have at least one external inbound link. Most importantly, we don't want to lose our existing link juice. Can we do some kind of match on each article name? Is writing the new 301 redirect lines in our .htaccess the best way to go, or is there a better option?
Thank you in advance for your suggestions.
I can tell you what I did and when i had a situation just like yours.
For some URL restructuring problem, I had to 301 redirect about 900 pages in my forum. A plugin actually created that problem. So I wrote 900*3 [*3 because of some URL structure issues] which equals to 2700 plus few more lines in .htaccess file.
I did that and after a year or so, I came to know about the URL removal option in GWMTs. So I thought why not remove all these redirects and remove the old pages via this feature in GMWTs.
I did that: all old URLs were removed by Google and my .htaccess file was empty again. Now after 1+ years of doing that: I see no change in anything. Everything seems to be the same as they were 2+ years back when I did not used that plugin which messed up all URLs.
But reading Doc and Kgun comments, it looks like too much redirects can cause a penalty. May be I did not got it, but you should consider other options as well, in order to avoid any penalty.
office7
09-24-2009, 05:59 AM
Thank you Angilina and Dan for your comments. Dan, I had a close look at your suggested code. I can see that it would work very well if there was going to be just one subdir under /articles/
In fact, we will have 19 new subdirectories under /articles/ In my posts, I used /newdir/ as a variable for these 19 new subdirs.
To give you two examples:
http://www.businessperform.com/html/fear_factor.html and
http://www.businessperform.com/articles/fear_factor.html will redirect to http://www.businessperform.com/articles/management/fear_factor.html
http://www.businessperform.com/html/team_learning.html and
http://www.businessperform.com/articles/team_learning.html will redirect to
http://www.businessperform.com/articles/teams/team_learning.html
There is no rule that determines whether fear_factor.html and team_learning.html will redirect to the /articles/management/ subdir or the /articles/teams/ subdir or any of the other 17 new subdirs. These allocations are decided by a human (namely me). And this goes for all our 200 articles. I can't see a way of avoiding having 200 lines in the htacess file. But that's no bother at all. It's getting the mod_rewrite syntax right that worries me. Dan, how should I modify your excellent code to accommodate the 19 new subdirs? Thanks in advance for your great help. Much appreciated.
Regards, Les
There is another option, that doesn't use the server, but instead uses PHP. You could create a custom error handler in PHP that responds to requests for nonexistent files in the /articles/ and /html/ folders, which then searches the article folders to find the appropriate folder and redirects the client.
How familiar are you with PHP?
danlefree
09-24-2009, 05:48 PM
Ah, I had figured that it would be a manual process/resistant to a few simple rules... which is why I included a link to that PHP redirect script (http://www.webproworld.com/discussion-forum/89332-how-do-you-redirect-url-0a-splitting-up-html-extension-htm-0al.html#post459022) in my first post on this thread - the redirect script will serve you well if you have PHP access.
I would recommend that you use the PHP script instead of mod_rewrite directives if you know that there will not be any hard and fast filtering that can be performed.
Anyone who is familiar with PHP should have little difficulty setting that script up or modifying it to recursively search your site.
office7
09-24-2009, 09:17 PM
Thanks Dan,
Yes, my webhost supports php. I'll look through your sample php scripts. Thanks again for all your help.
Regards, Les
Canonical
09-30-2009, 04:43 PM
Last December we implemented a site redesign on our PR7 commercial site that had over 4000 pages on it. EVERY URL on the site changed. Previously they were all .asp/.aspx files, but because we converted to a CMS at the same time that we redesigned and reorganized the site... every URL changed to NOT have an extension.
As part of the redesign, we reorganized the structure of the the site, converted it to using Theme Pyramids, changed ALL navigation, renamed every page, added breadcrumbing, etc. I found pages that had 3-4 stacked redirects like you're talking about.
I implemented redirects for ALL of the pages. Pages that had previously used stacked redirects (A-->B-->C) and now needed to be redirected to yet another URL (D) where "un-stacked" (A-->D, B-->D, C-->D). So in the end I implemented far more than 4000 redirects using .htaccess files and ISAPI Rewrite.
We were NOT penalized. In fact 3-4 weeks after we cut over to the CMS and new redeisgn, our rankings and traffic were better than ever.
Don't be afraid of making massive changes to your site. It's not really a problem if do your research, plan it out in detail, and execute your plan well. It can be scary as hell, but you don't have to fear penalties. Google is aware that sites frequently change technologies, convert to CMSs, switch programming languages, etc. and that there will be global changes to a site (large or small).
I spoke to Cutts at Pubcon about it last Nov. Of course he recommended that if possible I should do it one section of the site at the time... but NOT because we'd be penalized, but because of the hit to our traffic. Fortunately, we spend millions per month on Adwords, CPM advertising, etc. so the hit for us on organic search volume wasn't that big of a deal.
I think it's MUCH better to take the hit once and just deal with the fact that while the search engines are recrawling all of your inbound links discovering the 301s and transferring credit, reindexing all of your pages, absorbing all of the changes to your templating and interlinking of pages, redistributing PR, etc. you ARE going to take a hit on organic traffic. But if you do it during an off-season or increase your PPC budget during that time to compensate, you can minimize the impact. If you've done your job right, the rankings and therefore traffic WILL return.
You might find some useful information to help you plan for the changes and put your mind at ease on a recent post I wrote about web site redesign with SEO in mind (http://www.canonicalseo.com/site-redesign-and-seo/).
PS: If you're hosted on Apache, I'd HIGHLY recommend you familiarize yourself w/ regular expressions and use Mod Rewrite to implement your redirects. It requires a bit of a learning curve but once you understand it, it's incredibly powerful and runs VERY fast. Trying to implement massive 301 redirects in code sucks. And it means those old pages have to remain there indefinitely. If you implement the redirects in Mod Rewrite/.htaccess files then once you've confirmed all of your redirects are working, you can delete you old pages that are being redirected leaving only some .htaccess files and your new code on the server.
danlefree
09-30-2009, 05:06 PM
If you're hosted on Apache...
Trying to implement massive 301 redirects in code sucks. And it means those old pages have to remain there indefinitely. If you implement the redirects in Mod Rewrite/.htaccess files then once you've confirmed all of your redirects are working, you can delete you old pages that are being redirected leaving only some .htaccess files and your new code on the server.
The original poster is on Apache ("we are on an Apache box") and the recommended solution was a PHP 404 handler script combined with mod_rewrite.