News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

[Solved] 404.php

Started by andrea, September 19, 2004, 10:32:40 AM

Previous topic - Next topic

andrea

How is it possible to activate "404.php" instead of the "404.shtml" ?

Does one have to change server settings or cpanel settings for that?

Andrea Hubacher
Ex Lead Support Specialist
www.simplemachines.org

Personal Signature:
Most recent work:
10 Aqua Themes for SMF



[Unknown]

I think it's in CPanel.  I know it's in .htaccess too.

-[Unknown]

Owdy

Open Notepad or similar. Write this in it
ErrorDocument 404 http://www.andreasite.com/404.php

Save that file by name '.htaccess' and put it in your domains root. Its important that its named only .htaccess, not .htaccess.txt or other. More info: http://www.yourhtmlsource.com/sitemanagement/custom404error.html
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

andrea

Thx for the replies.

I got a custom 404.php working. However the $_REQUEST['HTTP_REFERER'] is not set so I don't know which file the user tried to get.

I added this lines into .htaccess:


#Custom 404 Error Page

ErrorDocument 404 http://www.mysite.com/mypath/404.php


Is it possible to modify that .htaccess line such that the pathname of the missing file is passed to the 404.php file?

Andrea Hubacher
Ex Lead Support Specialist
www.simplemachines.org

Personal Signature:
Most recent work:
10 Aqua Themes for SMF



[Unknown]

I use:

ErrorDocument 404 /404.php

And then:

$_SERVER['REDIRECT_URL']

-[Unknown]

andrea

Quote from: [Unknown] on September 19, 2004, 06:48:58 PM
$_SERVER['REDIRECT_URL']

Thx again for replying. I did already check this variable and also all other $_SERVER variables. None contains the wrong URL.

Can it be somehow activated in the .htaccess that this or another variable is passed?

Andrea Hubacher
Ex Lead Support Specialist
www.simplemachines.org

Personal Signature:
Most recent work:
10 Aqua Themes for SMF



[Unknown]

I'm not sure.  It works here... or at least seems to.  If you use print_r on $_SERVER, does anything have the URL at all?

-[Unknown]

andrea

I tried already these commands:
print_r($_SERVER);
print_r($GLOBALS);

nothing has the wrong URL in. I also tried already different browsers. It looks like all these "REDIRECT_" variables are simply not set...

Andrea Hubacher
Ex Lead Support Specialist
www.simplemachines.org

Personal Signature:
Most recent work:
10 Aqua Themes for SMF



andrea

#8
Submitting now a support ticket to the provider...

I definitely need the information about the missing URL, because I change a full website from .html files to .php files. There are around 400 html files on that site so I need to make an automatic redirect to the corresponding .php file...

Andrea Hubacher
Ex Lead Support Specialist
www.simplemachines.org

Personal Signature:
Most recent work:
10 Aqua Themes for SMF



[Unknown]

Do you have mod_rewrite?

-[Unknown]

Saleh

I am not sure if SHTML can include php files and excute them ,,
but SHTML has this requested URL var:
<!--#echo var="REQUEST_URI" -->
I think you already know that, but can't SHTML include php ?

We don't need a reason to help people

andrea

Quote from: [Unknown] on September 20, 2004, 05:10:53 AM
Do you have mod_rewrite?

I guess that yes, since phpinfo shows mod_rewrite among the "Loaded Modules".

Quote from: NeverMind on September 20, 2004, 08:57:21 AM
I am not sure if SHTML can include php files and excute them ,,
but SHTML has this requested URL var:

I think you already know that, but can't SHTML include php ?

PHP should have that variable too. I guess if PHP does not have it SHTML won't have it either.

In the meantime I checked the same thing on a 2nd server where it worked fine. So it might be a server setting, I have submitted a help ticket at the provider's helpdesk.

Andrea Hubacher
Ex Lead Support Specialist
www.simplemachines.org

Personal Signature:
Most recent work:
10 Aqua Themes for SMF



andrea

Starting to catch the problem:

The reason for the problem must be some stuff which is set by cpanel into the .htaccess file. I have namely some password protected directory on that server. The passwords for those are maintained by cpanel which hence modifes .htaccess files.

I made a new test directory in a non password protected area and created there a fresh .htaccess file with vi - and voilà - here all desired variables are set perfectly!

Andrea Hubacher
Ex Lead Support Specialist
www.simplemachines.org

Personal Signature:
Most recent work:
10 Aqua Themes for SMF



andrea

#13
Solved!

And that is the solution how the variable REDIRECT_URL (or REQUEST_URI) is properly set:

1st: the ErrorDocument ... line must be *after* the cpanel stuff, on the last line in the .htaccess file

2nd: the ErrorDocument ... line must be of the form
QuoteErrorDocument 404 /absolutepathtoyour/404.php

(it must not be http://absolutepathtoyour/404.php)

Andrea Hubacher
Ex Lead Support Specialist
www.simplemachines.org

Personal Signature:
Most recent work:
10 Aqua Themes for SMF



Owdy

Quote from: andrea on September 20, 2004, 01:38:02 PM

2nd: the ErrorDocument ... line must be of the form
QuoteErrorDocument 404 /absolutepathtoyour/404.php

(it must not be http://absolutepathtoyour/404.php)
It works in my server like that ;) Dont have cpanel though,
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

andrea

Quote from: Owdy on September 20, 2004, 04:14:53 PM
Quote from: andrea on September 20, 2004, 01:38:02 PM

2nd: the ErrorDocument ... line must be of the form
QuoteErrorDocument 404 /absolutepathtoyour/404.php

(it must not be http://absolutepathtoyour/404.php)
It works in my server like that ;) Dont have cpanel though,

The pure loading of the custom page works like this. But you haven't the variables set which are needed to make automatic redirects.

Andrea Hubacher
Ex Lead Support Specialist
www.simplemachines.org

Personal Signature:
Most recent work:
10 Aqua Themes for SMF



Advertisement: