Jump to content

404 error redirects


deansaddigh

Recommended Posts

ok so i have a 404 error redirect which works well. my question is

 

if you got to here the page displays

 

http://www.languageschoolsuk.com/student_photos.htm

 

but say you miss spell it like this

 

http://www.languageschoolsuk.com/stuent_photos.htm

 

it takes me to a blank page.

 

why doesnt the 404 error come up.

 

Kind regards

 

Dean

 

 

Link to comment
https://forums.phpfreaks.com/topic/212531-404-error-redirects/
Share on other sites

erm well thats a good question.

 

if you go here

 

http://www.languageschoolsuk.com/school_details and forget the trailing slash it works

 

heres my htacess file

 

RewriteEngine on

#change mask php files
RewriteRule ^(.*)\.htm$ $1.php [NC,L]

#seo friendly url
RewriteRule ^school_details/([a-zA-Z_|.-]+)/? school_details.php?id=$1 [L]

#prevent hotlinking
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?languageschoolsuk\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://img251.imageshack.us/img251/4224/logovg.png [L]

#compress php files to save bandwidth
<ifModule mod_php4.c>
php_value zlib.output_compression 16386 
</ifModule>

ErrorDocument 404 /404.php

Link to comment
https://forums.phpfreaks.com/topic/212531-404-error-redirects/#findComment-1107239
Share on other sites

Playing around with different addresses on your server (handy it being live, most peoples aren't) it would seem that your host has set-up your server so that ErrorDocument cannot be set for files with a .php extension. I'm not entirely sure how or why this is done. But that is almost certainly the case. Is it shared hosting? You might need to contact them and find out why.

Link to comment
https://forums.phpfreaks.com/topic/212531-404-error-redirects/#findComment-1107244
Share on other sites

I mean that URI requests to the server which end in a .php file extension will not trigger the ErrorDocument page, i.e. requests to something like...

 

domain.com/blah.php

 

...won't trigger the error document, but ...

 

domain.com/blah.foo 

 

...will. Remember that although in your example you were requesting .htm, this is being rewritten to php.

 

As I said I'm not entirely sure how they have done this, they must have something in their .conf files along the lines of...

 

<files .*\.php>
# disabled here
</files>

 

How exactly it's disabled though I'm not sure. Looking at the docs I can see that ErrorDocument overrides FileInfo, but so does mod_rewrite so they can't have disabled that. So unless they can set a default value, which isn't overridden I don't know (may have a look later out of morbid curiosity).

Link to comment
https://forums.phpfreaks.com/topic/212531-404-error-redirects/#findComment-1107265
Share on other sites

Oh yeah i see, how very annoying.

 

good news ive fixed it.

 

basically in the control panel, they have custom error pages, so i just set the 404 error to be 404.php and it seems to have fixed it, maybe they have an overide function that overides htaccess . and you have to use there custom error pages in the control panel

 

Thanks again man

Link to comment
https://forums.phpfreaks.com/topic/212531-404-error-redirects/#findComment-1107266
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.