Welcome to Geeklog, Anonymous Friday, April 26 2024 @ 09:02 pm EDT

Geeklog Forums

How to produce normal 404-pages again?


Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
I just noticed that the current GL-version doesn`t have normal 404-pages anymore. It delivers content if a page cannot befound. Thus several pages are not being delisted in Google.

What can I do?

~~~
it concerns static pages and stories
 Quote

Status: offline

Laugh

Site Admin
Admin
Registered: 09/27/05
Posts: 1468
Location:Canada
I have a similar issue except I needed to change the id of a staticpage and needed a 301 redirect with the old id. I couldn't get the redirect to function properly on IIS so I hacked the staticpage plugin. I hate hacking plugins as it can make upgrades a pain but here is what I did around line 84 fo the file \public_html\staticpages\index.php

Text Formatted Code

// Hack:
if (strtolower($page) == 'old-page-name') {
    Header( "HTTP/1.1 301 Moved Permanently" );
    Header( "Location: http://www.mysite.com/staticpages/index.php?page=new-page-name" );
    exit;    
}
// ***
 

One of the Geeklog Core Developers.
 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
Wouldn`t normal 404-pages be a matter of GL rather than the plugin? I just tested a few plugins an they all display some sort of text rather than a 404. Couldn`t one hack GL a little?
 Quote

Status: offline

Laugh

Site Admin
Admin
Registered: 09/27/05
Posts: 1468
Location:Canada
For stories sure, you would just have to make sure that the reason the story is not available to the user is not a security privilege problem.

For 404 errors with other plugins Geeklog could handle the page but it would have to check with the plugin if the item exists or not.

With my 301 problem Geeklog would need the extra piece of info of which page it should redirect too depending on the page requested. For this reason I was thinking of creating a small plugin for it or adding it to one of the other admin plugins out there.

Tom

One of the Geeklog Core Developers.
 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
I made this 404 a feature request: http://project.geeklog.net/tracking/view.php?id=1199 I don`t know with the 301 it i a separate thing but certainly also a good idea.
 Quote

Status: offline

Laugh

Site Admin
Admin
Registered: 09/27/05
Posts: 1468
Location:Canada
Stupid me. I had checked this before I hacked the staticpages plugin but I missed the blank page format options.

Anyways for staticpages set the Page Format to Blank page. You then enable Execute Php and then put

Text Formatted Code

header('HTTP/1.0 404 Not Found');
 


For your 404 file not found error

For a 301 redirect you would put

Text Formatted Code

header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: http://www.mysite.com/staticpages/index.php?page=my-new-page" );
 

One of the Geeklog Core Developers.
 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
So do I need your above hack then? Or just that one line?
header('HTTP/1.0 404 Not Found'Wink; BTW, this alone dos not work.
 Quote

Status: offline

Laugh

Site Admin
Admin
Registered: 09/27/05
Posts: 1468
Location:Canada
You do not need the hack. I just tried the 404 error code and it worked fine (the browser returned a page not found message instead of Geeklog)

Lets review what you need to do.

1. Create a new staticpage

2. Fill in the following Fields:
Title: 404 Not Found
Page Format: Blank Page
ID: the id of the staticpage you want not found.
Content: header('HTTP/1.0 404 Not Found'Wink;
PHP: execute PHP

3. Save the Page


One of the Geeklog Core Developers.
 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
O.k., I`m trying that and I only receive a blank page without a title. The URL is the page that is not to turn up but to produce a 404.
php is enabled with static pages.
 Quote

Status: offline

Laugh

Site Admin
Admin
Registered: 09/27/05
Posts: 1468
Location:Canada
That is probably working then. Google Search Bot would look at the header and see a 404 error.

You can check for sure by entering your url here

http://www.seoconsultants.com/tools/headers

It you want a 404 message that a visitor can read you would have to add in some html.

Tom
One of the Geeklog Core Developers.
 Quote

All times are EDT. The time is now 09:02 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content