peppericious Posted July 27, 2011 Share Posted July 27, 2011 I have a htaccess file which causes redirects to a custom 404.php page when files can't be found. The htaccess file contains the following code: php_value upload_max_filesize 50M php_value post_max_size 50M php_value max_execution_time 6000 php_value max_input_time 6000 php_value memory_limit 128M php_flag magic_quotes_gpc off php_flag display_errors on ErrorDocument 404 /404.php So, pages such as mydomain.com/filethatcantbelocated.php redirect to the 404.php page without problem. However, pages like mydomain.com/somedirectory/filethatcantbelocated.php don't result in the 404.php page being displayed properly. Css files in the header include are not being referenced properly or something. At the top of the 404.php page, there's this code: <?php session_start(); include("lib/inc/inc.header.php"); ?> Can someone please tell me what I need to do - either to the htaccess file or to the 404.php page - in order to fix this problem? Your help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/242926-htaccess-and-custom-404-page/ Share on other sites More sharing options...
cags Posted August 4, 2011 Share Posted August 4, 2011 You need to edit inc.header.php and change the src paths for your css /images, they need to be paths relative to root not relative to the current file (they should either be full paths beginning with your domain or they should begin with a forward slash. When the 404 document is displayed it appears to the user that it's location is the URI they requested. Therefore if your css path is 'styles/base.css', a request for /somefolder/somefile.html will make the clients browser attempt to download yoursite.com/somefolder/images/base.css, if you simply changed the path to be '/styles/base.css' it would always request yoursite.com/styles/base.css. It can get a little confusing working out the difference between using server relative paths and client relative paths. Quote Link to comment https://forums.phpfreaks.com/topic/242926-htaccess-and-custom-404-page/#findComment-1251799 Share on other sites More sharing options...
peppericious Posted August 4, 2011 Author Share Posted August 4, 2011 You need to edit inc.header.php and change the src paths for your css /images ... Really appreciate your help with this. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/242926-htaccess-and-custom-404-page/#findComment-1251841 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.