Forum Moderators: phranque

Message Too Old, No Replies

301 old urls from search engines

301 old urls from search engines

         

dirkfreak

8:30 am on Jan 13, 2010 (gmt 0)

10+ Year Member



The last year search engines have indexed urls like:
mysite.com/somedir/somedir/54980/remove-text-2.htm

But now I have new static pages with a different urls like:
mysite.com/somedir/somedir/54980.htm

I need a 301 redirect that removes "/remove-text-2" for all my pages so the new url become: mysite.com/somedir/somedir/54980.htm

So I think I need a htaccess rule that looks at the uri and send a 301 redirect to our new urls for the search engines..

Well I hope you understand my question and can help me

Thanks again

g1smd

10:53 am on Jan 13, 2010 (gmt 0)

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



You're correct in your assumptions, and that redirect should clarify the protocol and domain at the same time it fixes the path part of the URL request. What code have you tried so far?

There have been at least two similar questions in the last 48 hours, so a perusal of old threads here should find plenty of examples to get you started. We can help you fix your code, but at the end of the day anything you add to your server configuration file must be fully understood by you so that you can maintain it in the future.

dirkfreak

12:36 pm on Jan 13, 2010 (gmt 0)

10+ Year Member



Well the problem is that I don't have any experience in this area...

I have seen many examples but I can't make one that I can use and understand

So I was hoping someone can give me same examples...

jdMorgan

4:38 pm on Jan 13, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you currently have any other Redirect, RedirectMatch, or RewriteRule directives in your .htaccess file(s)?

Jim

dirkfreak

5:05 pm on Jan 13, 2010 (gmt 0)

10+ Year Member



Only:

AddType text/html .shtml .html .htm
AddHandler server-parsed .shtml .html .htm

(This make the old urls still working when they came from google)

<Files *xml>
ForceType application/x-httpd-php
</Files>

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [nc]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

[edited by: jdMorgan at 5:48 pm (utc) on Jan. 13, 2010]
[edit reason] example.com [/edit]

jdMorgan

5:59 pm on Jan 13, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Because you've already got some mod_rewrite code in place, I suggest that you *not* mix in any mod_alias redirects, as this often causes unexpected results (as in another thread posted here today).

So you need to add a RewriteRule that removes the unwanted path-part, and place it *before* your domain canonicalization rule:


# Externally redirect requests for URL-path "/somedir/somedir/<numbers>/<any-text>.htm"
# to "http://www.example.com/somedir/somedir/<numbers>.htm"
RewriteRule ^somedir/somedir/([0-9]+)/[^.]+\.htm$ http://www.example.com/somedir/somedir/$1.htm [R=301,L]

In order to keep things simple, I've assumed that the /somedir/somedir/ path is fixed and that only the "number" and "remove-text-2" parts of this URL-path vary. If this assumption is not correct, then the code won't be correct either, and you'll need to be more specific about which parts of the incorrect URLs' paths are fixed, and which are variable.

Jim

dirkfreak

8:56 am on Jan 14, 2010 (gmt 0)

10+ Year Member



Thanks mate your Rule works great..

There is only one little problem.. this /<numbers>/ don't exist as directory on my server, so I had to create for every <numbers> an map on my server..

I am not sure if this is possible, but is there no rule that looks at the uri... Or will this return as a bad 301 ?

g1smd

7:25 pm on Jan 14, 2010 (gmt 0)

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



RewriteRules do examine the URL request, so I don't understand the question.

jdMorgan

8:18 pm on Jan 14, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> so I had to create for every <numbers> an map on my server..

No you didn't. You should have reported the problem here instead.

You've got some other code somewhere that is grabbing these requests before the rule can get control.

Try adding


AcceptPathInfo off
Options +FollowSymLinks -MultiViews

ahead of "RewriteEngine on"

Also, only include the "AcceptPathInfo off" directive if you're on Apache 2.x -- It will cause an error if you try to use it on Apache 1.3 or earlier.

If this doesn't help, then please let us know if you've used a 'control panel' to install any blog, forum, or shopping cart, or to make any other URL-affecting settings changes.

Jim

dirkfreak

7:18 am on Jan 15, 2010 (gmt 0)

10+ Year Member



Your the best mate... and sorry that I created this maps to fast..

I added your extra line: Options +FollowSymLinks -MultiViews

Thanks again.. everything is working now ;-)

dirkfreak

2:08 pm on Jan 15, 2010 (gmt 0)

10+ Year Member



BTW Is it normal that my traffic is low from google after a 301? And how long will it take before google update my links

jdMorgan

6:38 pm on Jan 15, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> BTW Is it normal that my traffic is low from google after a 301?
Are you asking about search-user traffic or googlebot traffic?

Actually, I don't think you could possibly see any effect on traffic this soon. Wait until your logs show that google has spidered all of these pages twice before you even start to worry about such things. And as the code appears to be correct, there's really nothing to worry about: Your traffic may drop for a few weeks, but should return to normal after that. The drop has to do with the time needed for google to 'assign' the PageRank of your old URLs to your new URLs, and that can only be done after at least one complete crawl cycle.

> And how long will it take before google update my links?

A few weeks, a few months, or not until October, 2010 -- It all depends on how frequently googlebot crawls your site, and how much it trusts and esteems your site... The index should update at about the same time you see the second of two complete crawl cycles.

Jim

dirkfreak

8:53 am on Jan 16, 2010 (gmt 0)

10+ Year Member



Okay thanks for the info Jim....