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?
I think it's in CPanel. I know it's in .htaccess too.
-[Unknown]
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
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?
I use:
ErrorDocument 404 /404.php
And then:
$_SERVER['REDIRECT_URL']
-[Unknown]
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?
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]
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...
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...
Do you have mod_rewrite?
-[Unknown]
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 ?
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.
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!
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)
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,
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.