htaccess non existing pages

Creating and modifying plugins.
Post Reply
gamespel
Regular
Posts: 17
Joined: Mon Jul 04, 2005 8:21 pm

htaccess non existing pages

Post by gamespel »

I have a problem on my site http://www.spellenblog.nl

When you go to the site everything is o.k., but when you write a wrong url like http://www.spellenblog.nl/werwer it displaying the index.php page.

Is there a way to change it that it goes to /errordoc/404.html ?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: htaccess non existing pages

Post by garvinhicking »

You can do that by editing your Serendipity Configuration and setting URL Rewriting to "none".

You will loose the "pretty" URLs when doing this, though. If you really need a 404 page, you can edit your index.php file and look for

Code: Select all

} else {
    header('HTTP/1.0 404 Not found');
    include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
    // printf('<div class="serendipity_msg_important">' . DOCUMENT_NOT_FOUND .
}
Change that include_once to include the 404 file you want to show. Or replace it with "exit;" instead, then your users only get a 404 error.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
gamespel
Regular
Posts: 17
Joined: Mon Jul 04, 2005 8:21 pm

Post by gamespel »

When I replace the original page ( include/genpage.inc.php ) into errordoc/404.html I get a fatal error

Fatal error: Call to a member function on a non-object in /xxx/xxx/xxx/www.spellenblog.nl/htdocs/index.php on line 314
MySchizoBuddy
Regular
Posts: 340
Joined: Sun Jun 12, 2005 5:28 am

Post by MySchizoBuddy »

i actually like this rewrite .:)
however i t does not completely render the page. the logo doesnt display.
if u go to http://myschizobuddy.com/uploads/ it goes back to index.php, but the logo is missing from the site :?
Image
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

MySchizoBuddy - the logo is missing because:

Code: Select all

<img src="templates/leaf/img/logo.png" alt="Logo" />
you are using a relative directory reference here. It should rather look like this:

Code: Select all

<img src="/templates/leaf/img/logo.png" alt="Logo" />
Gamespel: Please show me how you modified it exactly. I'm afraid you made a typing mistake there, hence the error.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
gamespel
Regular
Posts: 17
Joined: Mon Jul 04, 2005 8:21 pm

Post by gamespel »

If changed:
include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');

into:
include_once(S9Y_INCLUDE_PATH . 'errordoc/404.html');

I have also tried:
include_once(S9Y_INCLUDE_PATH . '/errordoc/404.html');
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Okay, please try to add an "exit;" after the include line:

Code: Select all

include_once(S9Y_INCLUDE_PATH . 'errordoc/404.html');
exit;
That should do the trick?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
gamespel
Regular
Posts: 17
Joined: Mon Jul 04, 2005 8:21 pm

Post by gamespel »

Yes this works....

Thanks Garvin
Post Reply