Forum Moderators: phranque

Message Too Old, No Replies

301 redirect htaccess code order

         

riospace

3:17 pm on Jan 11, 2007 (gmt 0)

10+ Year Member



I recently used the following .htaccess code to move 2 directories. Should this code come before or after my 301 www/non-www, canonization code? Is the following the correct order?

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain\.com
RewriteRule ^(.*)$ [yourdomain.com...] [R=permanent,L]

RewriteRule ^directory_1/directory_2/(.*)$ http://www.example.com/directory_1/$1 [R=301,L]

RewriteRule ^directory_1/directory_3/(.*)$ http://www.example.com/directory_1/$1 [R=301,L]

Also, less than 24 hours after I put this change into effect, all of my pageranks have gone from 5 or 6 to 0. I was expecting this to happen only to the directories that I was moving until Google caught up, but why did this happen to all 3,000 pages? Yes, I did remove my old directories after I making the change.

riospace

3:36 pm on Jan 11, 2007 (gmt 0)

10+ Year Member



Also, if I add the following code where should it go in the order with the other codes above?

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]*/)*index\.(html?Šphp)\ HTTP/
RewriteRule ^(([^/]*/)*)index\.(html?Šphp)$ [www\.example\.com...] [R=301,L]

One more question, I have used this code in the past, but was not sure if I needed to change all of my internal links site-wide that are pointing to example/index.html to point to example/ or can I just leave them alone? Almost every link on my site points to example/index.html.

wilderness

4:05 pm on Jan 11, 2007 (gmt 0)

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



riospace,
I'm here to tell you that using redirects for invalid links within your website (s), should ONLY be a temporary solution until you repair the invalid links.

There are some softwares (free) that will correct many pages in directories and multiple sub-directories in seconds.

I use one named "Search and Replace 98".

Hopefully another will come along and assist you with a TEMPORARY rewrite solution.

jdMorgan

4:35 pm on Jan 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Generally, put your redirects in most-specific to least-specific order. That is, redirect individual pages first, then finally, do the domain canonicalization redirect.

Thes rules are then followed by your internal rewrites (if any).

You must change the links on your pages to point to "/", not index.xyz, both to improve usability and to avoid confusing the search engines.

More generally, you should change all links to your old URLs to point to the new ones.

Be aware that if you link to "index.xyz" and then redirect "index.xyz" to "/", every visitor clicking that link will have to wait for two connections to your server -- the first that returns the redirect response, and the second to display the page you redirected his browser to. The same is true if the visitor is a search engine.

The current consensus is that it will take up to 90 days for Google to re-analyze your site, re-assign PageRank, and display its new value on the Google toolbar, with this last step taking the longest, since it is not a priority for them.

Jim

riospace

7:12 pm on Jan 11, 2007 (gmt 0)

10+ Year Member



So, the changing (moving) of a directory can cause a site to temporarily loose all page ranks (even pages that where not moved) until Google reevaluates the site. Is this correct?

jdMorgan

7:52 pm on Jan 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, you may have just removed almost all of the incoming links to most of your pages, because you changed their URLs. Google assigns PageRank to URLs, not to site and not to "pages".

Jim

riospace

12:55 am on Jan 12, 2007 (gmt 0)

10+ Year Member



I thought that the incoming links still counted, as far as Google goes, because of my 301. Oops! Now I wish I did not make the change.

jdMorgan

1:18 am on Jan 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



They *will* count, after 30 to 90 days.

Of course, if you change back now, the 30-to-90 day clock will just start over... :(

Jim

TinkyWinky

11:04 am on Jan 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, you may have just removed almost all of the incoming links to most of your pages, because you changed their URLs. Google assigns PageRank to URLs, not to site and not to "pages".

Hi Jim,

Sorry can you clarify - if most IBL's are to pages that are not being moved - surely those pages remain as is as do the IBL's therefore there should be no need to re-evaluate? It would only be the pages or directories that are moved that would have to be reevaluated?

Or am I wrong and because google see's that some pages have been moved - the whole site is 'penalised' in that it all needs to be re-evaluated not just those pages that are removed?

Sorry this is quote important as we want to move about 300 pages from the root to a more structured architecture...

Thanks for any help on this one.
REgards
TW

jdMorgan

4:42 pm on Jan 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> It would only be the pages or directories that are moved that would have to be reevaluated?

No, because presumably, the pages that have moved also link to the pages that have not moved. Therefore, their effect on the ranking of the non-moved pages must also be re-evaluated.

By renaming a page, you disconnect it from its inbound links until the redirect is processed by the search engine ranking algorithm. However, you also remove that page's "power" to pass PR or link-popularity to other pages on your site, because the relocated pages temporarily have no PR or link-pop to pass.

Forget about "penalties" -- Our individual Web sites have minuscule importance to the search engines, and they can't be bothered with per-site penalties except in the most egregious cases.

That is, if you know you are intentionally cheating the search engines and breaking all the rules, then you may get a true penalty if your site is highly-ranked across many keyword spaces to which your site is not truly relevant. If not, then you're not going to get a "penalty." You may trip a "filter" in the search algorithms, but the word "penalty" and the paranoia it instills are far too prevalent in Webmaster discussions.

Jim

jdMorgan

4:46 pm on Jan 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Also, if you want to move files around on your server, that has nothing whatsoever to do with your URLs. URLs and filepaths are two entirely different things, and you can use mod_rewrite to translate or "map" the pre-existing URLs to the new filepaths without changing the URLs in any way.

This can be very simple if the URLs to be re-mapped have something in common. If not, you can still rewrite them on an ad-hoc basis, though that might require 300 lines of code.

Look into the difference between an internal server rewrite and an external redirect to clarify this point.

Jim

TinkyWinky

8:34 pm on Jan 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Jim - I will take your advice and read up on the differences before we do anything.

Basically if I understand this right (sorry if I have completely missed the point - it has been a very long day!), if we want to move the 'location' of a file in order to place into a new site structure that's scalable, we will have to bite the bullet and do 301's with the consequence of an expected PR drop.

I am not overly bothered about the lovely PR green bar (stopped caring about that months and months ago) all I'd like to know is whether all site pages drop like a stone within the SERPs whilst google re-assesses the changes (we are also putting a completely new site design live at the same time!).

Any one with some experience of this and how much traffic you do lose?

We have advertisers that pay good money for the traffic they receive and I don't want to upset them by losing 80% of their traffic overnight!

Thanks again for help.

jdMorgan

9:27 pm on Jan 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you change URLs, those URLs will lose traffic and rank for 30 to 90 days on average. The pages they link to will also drop, with the degree of drop determined by how much those non-moved pages depend on links from the moved pages.

If you "release a redesigned site" then your whole site may drop, as Google re-assesses it to make sure it hasn't changed themes, or owners, or linking patterns, etc.

With respect, it sounds like your organization needs to step back and re-evaluate the Web. You are apparently treating your Web site like a print catalog, and thinking that you can and should change it in drastic ways periodically. This discards the search ranking "credit" that age and stability of site content, structure, and linking has given your site.

If you are an Amazon.com with overwhelming 'branding' and astronomical link-popularity, then you can indeed ignore these factors. If not, beware.

The search engines see the Web as it was originally intended; As a collection of documents, preferably permanently-accessible at the same URLs, and to be used for academic research purposes. Although on-line commerce is 'tolerated,' the model above is what the search engines are built on. So accept that and adapt your on-line marketing strategy to that model.

Permanent URLs. Pages perpetually available. A library, not a newstand or advertising kiosk. Design your URL- and file-structures with this model in mind, along with your needs for future growth, so that you won't ever have to discard URLs again. A well-organized site can go for a decade with only a handful of deprecated URLs, while the content is updated and the appearance kept fresh through the use of CSS.

I have already suggested several times that you rewrite and not redirect your old URLs. It falls to you to research this, as I am now repeating myself.

Jim