Custom 404 error page

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Custom 404 error page

Post by jaoudestudios »

pytrin wrote:Does the .htaccess file in the script directory has the proper AllowOverride settings? (AllowOverride All)
http://httpd.apache.org/docs/2.0/custom-error.html
Ah hah, half way down the httpd.conf file....Nope it does not :( . Spot on pytrin

I recommend backing up your current httpd.conf file and then make changes - that way you can always go back to the original.

Currently you have this in your httpd.conf file...

Code: Select all

<Directory />
    Options SymLinksIfOwnerMatch
    AllowOverride None
</Directory>
But you need this...

Code: Select all

<Directory />
    Options SymLinksIfOwnerMatch
    AllowOverride All
</Directory>
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Custom 404 error page

Post by Eran »

Better not to change the global setting - create an .htaccess file in the directory you want this to perform, or create a directory container for that specific directory in the httpd.conf file:

Code: Select all

<Directory "/path/to/specific/directory" />
    AllowOverride All
</Directory>
Jordi
Forum Newbie
Posts: 20
Joined: Wed Jan 14, 2009 8:37 am
Location: Barcelona, Spain

Re: Custom 404 error page

Post by Jordi »

I just changed that, and.. you can see for yourself.. http://www.catalansoft.com/flightschool/f.pp still showing looping behaviour.
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Custom 404 error page

Post by jaoudestudios »

You will need to restart apache after any config changes.
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Custom 404 error page

Post by jaoudestudios »

Graceful might be enough.

Code: Select all

# graceful restart
apachectl graceful
or
# full restart
service httpd restart
EDIT: typo
Last edited by jaoudestudios on Wed Jan 14, 2009 1:20 pm, edited 1 time in total.
Jordi
Forum Newbie
Posts: 20
Joined: Wed Jan 14, 2009 8:37 am
Location: Barcelona, Spain

Re: Custom 404 error page

Post by Jordi »

my .htaccess file now is:

Code: Select all

 
<Directory "/var/www/flightschool/" />
    AllowOverride All
</Directory>
ErrorDocument 404 http://jordiserres.homeip.net/flightschool/error.php
 
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Custom 404 error page

Post by jaoudestudios »

The <directory "/var..... goes in the httpd.conf file not in the .htaccess file.
Jordi
Forum Newbie
Posts: 20
Joined: Wed Jan 14, 2009 8:37 am
Location: Barcelona, Spain

Re: Custom 404 error page

Post by Jordi »

Sorry guys, but still crazy. I did restart the server after applying the changes, without success.
The current version of the .htaccess file follows, and the http.conf file is now unaltered.

Code: Select all

 
<Directory "/flightschool" />
    AllowOverride All
</Directory>
ErrorDocument 404 http://jordiserres.homeip.net/flightschool/error.php
 
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Custom 404 error page

Post by jaoudestudios »

Jordi wrote:

Code: Select all

 
<Directory "/flightschool" />
    AllowOverride All
</Directory>
ErrorDocument 404 http://jordiserres.homeip.net/flightschool/error.php
 
Your htaccess file should only contain 1 line...

Code: Select all

ErrorDocument 404 http://jordiserres.homeip.net/flightschool/error.php
Your httpd.conf file should contain...

Code: Select all

<Directory "/var/www/flightschool" />
    AllowOverride All
</Directory>
Jordi
Forum Newbie
Posts: 20
Joined: Wed Jan 14, 2009 8:37 am
Location: Barcelona, Spain

Re: Custom 404 error page

Post by Jordi »

No luck. I set the httpd.conf and .htaccess files as you suggested, restarted the server and.. everything is performing with no changes.

It's getting late for me, and I guess for you too. I'll try to fix it tomorrow and I'll let you know if I succeed.

Thank you so much for your help!
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Custom 404 error page

Post by jaoudestudios »

No problem. Sorry we did not manage to fix it yet. :(
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Custom 404 error page

Post by jaoudestudios »

OK OK OK. I think I have it!!?!?!!??!

I manage to get it working the other day when we were chatting, however, I was doing it all on my linux server. I just tried to do the same, i.e. create the .httaccess file on my windows machine and copy it over to my linux server and I got an internal server error. So i opened the file on the command line and some characters were corrupted. I re-wrote the file on the command line and all works fine.

Hope that helps!
Jordi
Forum Newbie
Posts: 20
Joined: Wed Jan 14, 2009 8:37 am
Location: Barcelona, Spain

Re: Custom 404 error page

Post by Jordi »

Thanks, jaoudestudios.
I couldn't carry on with this issue today, so I'll give it a try tomorrow and I'll let you know.
Jordi
Forum Newbie
Posts: 20
Joined: Wed Jan 14, 2009 8:37 am
Location: Barcelona, Spain

Re: Custom 404 error page

Post by Jordi »

Hi again!

After several tests, the issue is fixed now:
The problem was within these lines, formerly uncommented, that seem to apply an unwanted translation to each requested url within the site.

Code: Select all

 
#<Directory /var/www/>
#   RewriteEngine on
#   RewriteBase /
#   RewriteCond %{REQUEST_FILENAME} !-f
#   RewriteCond %{REQUEST_FILENAME} !-d
#   RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
#</Directory>
 
At least, after commenting these lines, the apache server shows the expected behaviour when trying to access a non-existing page: it shows either the standard "404: page not found" error or redirects to the file in the .htaccess file.

Thank you guys!
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Custom 404 error page

Post by John Cartwright »

As pytrin pointed out, this looks like an issue with your AllowOverride variable set to low.

I took a quick look at your httpd.conf and it appeared you are setting AllowOverride to the lowest permission ( AllowOverride None).
Post Reply