|
#1
|
|||
|
|||
|
404 Error Page/301 Redirect??
Hello All..
This may sound like a newbie question. In the past when I have taken over existing websites for SEO/SEM I always create a custom 404 page, or even re-direct that custom 404 page in my htaccess file to my homepage like so: ErrorDocument 404 http://www.logicalsense.ca/ My question is should I use 301 redirect instead or is my custom 404 error page, or directing the 404 error page to my homepage ok in preventing Google and other engines from hitting old/non-existent pages? Thanks Critter |
|
#2
|
|||
|
|||
|
That's what a 404 is 4 isnt it?
Nick |
|
#3
|
|||
|
|||
|
Quote:
I just want to be sure this is SEO friendly and won't pose any future problems.. Critter |
|
#4
|
|||
|
|||
|
Well, a 301 is for permenantly moved right? So, you use a 301 to redirect to where you have moved the content of the old page.
If the page no longer exists, use 404. Just good webmastering, but good for bots and humans alike.. Nick |
|
#5
|
|||
|
|||
|
Actually, I'm getting confused on this issue, too.
I would normally set up a 404 as critter detailed, so when pages are removed, you can redirect to the homepage or sitemap with a 404 redirect in .htaccess. However, recently I looked at using Google Sitemaps, and I'm told that this redirect is effectively sending 200 OK headers for pages removed from the site - so the removed pages are apparently still telling search engines that t hey are there, while moving human users appropriately. I tried setting up the 404 redirects as relative to the root domain - ie, "ErrorDocument 404 /" - but this shows the original URL on top of the page redirected to human users, and is effectively misleading them. What is the best way to apply a .htaccess redirect so that you send proper 404 headers to human user and search engines, as well as show the new URL redirected to so that everyone's clear? (Also, apologies for bringing up an old thread - I used Google site: search and this was the most appropriate of the first dozen listings). |
|
#6
|
||||
|
||||
|
Hi Brian,
It can be quite confusing. Status code definitions http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html are worth reading if you are an incurable insomniac. Basically, the server returns a status code in the http header in response to a page request - there are tons of different status codes (see link above). This is over simplifying it - but basically - the server returns one status code per page request, and a page. The 'top 4' responses are - the server either gives you the page you asked for - or- it sends you to the new page content location if it's moved -or- it can't find that page and gives you an 'error' page. i.e. 200 - which indicates the server has found the page (url) you requested, and here it is; 301 - the page you requested has permanently moved to a new URL - so I'll give you the new URL content; 302 - the page you requested has temporarily moved to a new URL - so I'll give you the new URL content; 404 - The page you requested can't be found, I haven't got a clue where it could be, no one told me about that page, so sod off and guess again. So: Quote:
If a page is removed, or never existed (i.e. you removed it, they mistyped it) then serve up a custom 404 content page (which you configure in .htaccess). Have the custom 404 'content' page explain (on the custom 404 page) that the page is no longer there, its gone, and provide full nav or a mini site map (on the custom 404 error page.) Its a semantic hair splitting, nit picking distinction - but: - you should return a 404 header - with a special page of content to help the user. Rather than: - Returning a 200 ok - and then giving them a 404 "page" (without a 404 header) or - returning a 200 ok - and then doing a redirection (301, 302) to another page (like home or sitemap) Search engines act on the header response. Give them a 404 header - they'll eventually stop requesting the page. Give them a 200 - and they keep coming back. Give them a 302 - and they'll index the original requested URL and the content of the redirection. If you moved it - and it won't ever go back to the old URL (e.g. you converted the site from .asp to .php) - then use a 301 to take them to the correct new URL (again - in .htaccess) - so the new URL is indexed, and the old one is dropped. So the .htaccess syntax for a customised 404 should be: ErrorDocument 404 /brians-404-error-page.html Where the url of your custom 404 page is brians-404-error-page.html and it is in the root directory. Use http://www.rexswain.com/httpview.html to see the header you are returning. Its pretty late here in Oz - does that help Brian? I've tried to explain it in broad terms - rather than cutting and pasting a complex RFC explanation. Last edited by Chris_D : 03-23-2006 at 08:35 AM. Reason: Typos/ clarify |
|
#7
|
|||
|
|||
|
That's a great help, Chris - thanks for that.
So much for working for human users, not for search engines. ![]() |
|
#8
|
||||
|
||||
|
No problem Brian. Sticky me if you get stuck with the .htaccess stuff.
Quote:
![]() |
|
#9
|
|||
|
|||
|
First of all, Chris, thank you for that detailed explanation. I now do my 404's through .htaccess.
I have an interesting twist on this topic and was wondering if anyone new a way of doing this through htaccess, or any other way... I will be moving a number of static pages over to dynamic pages and I'd like to 301 redirect them all. However, there are too many to redirect them individually. So, what I need is a page that checks the requested url to see if it matches the pattern of the old static pages and 301 redirects to the new url, or returns a 404 error if it doesn't match the pattern. Also, a few of the old pages have dissappeared all together. How would Search Engines feel about a 301 redirect to a 404? If that's a problem I may need to access my database to check to url. Is this even possible? Thanks, -Ben |
|
#10
|
||||
|
||||
|
Hi Ben
Sorry - missed your post. Quote:
i.e. you can have a static URL; or a dynamically generated URL. You can have 'static' content; or you can have dynamically generated content. Why not just keep the Static URLs - i.e. rewrite the new dynamic URLs into the old static ones? i.e. mod rewrite/ isapi rewrite (depending on your server flavour) Quote:
|
|
#11
|
|||
|
|||
|
Dear Chris..
thank you very much for your detailed explanation. i also had these doubts and i started to verify my .htaccess after your detailed xplanation. right now i have given a 404 redirect using errordocument code in my .htaccess. ErrorDocument 404 http://www.domain.com/notfound.htm but i checked a file which is not in the server(which should give a 404 error) using the tool u had specified and i got the following information. Quote:
Quote:
can u pls clarify on what has gone wrong? or is this normal? regards, deepak.c |
|
#12
|
||||
|
||||
|
Hi Deepak
Here are a few quick checks: 1. Is there anything else in your .htaccess file over riding the ErrorDocument 404? 2. Did you check the response using the Rex Swain tool? A few other 'similar' tools I've used don't always return the correct codes. 3. Does the .htaccess file have permissions set correctly? (telnet into your server and type chmod 644 .htaccess at the prompt). |
|
#13
|
|||
|
|||
|
Thanks Chris,
The old URL's are from an old ASP version of the site and many more topics have been added under the PHP design. Here's an example of what I did for anyone who's interested: Old pages were of the form "www.domain.com/topic_string.asp". New site was of the form "www.domain.com/index.php?pt=topic&ts=topic_string". I combined the two using .htacces and have both 301 redirecting to SEF versions of the PHP pages. The link is now "www.domain.com/t_topic_string". Here's the .htaccess code: Code:
Options +FollowSymlinks
RewriteEngine On
#########################
# 301 Redirects (Permanant Moves)
#########################
# Old ASP Pages
RedirectMatch 301 /(.*)\.asp$ http://www.domain.com/topic_$1
# Old PHP Pages
RewriteCond %{REQUEST_URI} ^/index.php$
RewriteCond %{QUERY_STRING} pt=topic&ts=(.*)
RewriteRule (.*) /cr_%1? [R=301,L]
#########################
# 404 Pages
#########################
ErrorDocument 404 /pnf.php
#########################
# MOD_REWRITES
#########################
# Topics
RewriteCond %{REQUEST_URI} ^/topic_(.*) [NC]
RewriteRule (.*) /newindex.php?pt=topic&ts=%1 [L]
I do wonder though, if search engines will hurt me because I have two different pages 301 redirecting to one page. Anyone know how this works and what rankings are kept? Cheers, -Ben Last edited by jamstooks : 04-10-2006 at 09:37 AM. |
|
#14
|
||||
|
||||
|
Quote:
RewriteCond %{HTTP_HOST} ^domain.com RewriteRule ^(.*)$ http://www.domain.com/$1 [r=301,L] I am using the above set of code to redirect non-www to www version of the site. But i belive this is also giving me a 302 code only.. Quote:
Quote:
thanx for taking the time and helping us out.. my htaccess file looks like this: Quote:
deepak Last edited by maildeepak : 04-10-2006 at 11:22 PM. |
|
#15
|
|||
|
|||
|
HTTP Header Tool
Thanks for all the good info guys.
I created an extension for firefox called HeaderGetter that makes it easy to test the Headers for the current page or any link. https://addons.mozilla.org/firefox/2526/ Thought it might be useful... -Ben |
|
#16
|
|||
|
|||
|
Dear Chris,...
I am eagerly waiting for your help regarding this below post. deepak Quote:
|
|
#17
|
|||
|
|||
|
Don't forget the $
Deepak,
You need to use '$' in the first line to mark the end of the line: Code:
RewriteCond %{HTTP_HOST} ^domain.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [r=301,L]
Quote:
-Ben |
|
#18
|
||||
|
||||
|
Re: 404 Error Page/301 Redirect??
there is a great article about 404 redirects and site migration
__________________
Grab a Halloween costume - marketing them can be fun too. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|