Welcome to WebmasterWorld Guest from 184.108.40.206 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
parsing php on only one shtml page Darla839 msg:4435611 4:25 pm on Mar 31, 2012 (gmt 0) All I want to do is include my header and footer into my 404 file, but of course include requires php, and the 404 is an shtml file. I've searched on and off for about year now, and have found many "solutions", but none of them work. How can I accomplish this? Below is the collection of "solutions" I've tried from various posts all over the internet, grouped by the actual results they achieve: Result: 500 Error redirect permanent 404.shtml 404.php Result: No redirect, goes to unparsed 404.shtml Result:ignores custom page; just goes to a generic "File not found" page <Files *.shtml>ForceType application/x-httpd-php</Files> AddType application/x-httpd-php .shtml <Files 404.shtml> ForceType application/x-httpd-php.php</Files> RemoveHandler .shtml AddType application/x-httpd-php .shtml AddType application/x-httpd-php .shtml Goes to the 404.shtml page, but no parsing. <FilesMatch "\.(shtm)$"> SetHandler application/x-httpd-php </FilesMatch> <FilesMatch "404.(shtm)$"> SetHandler application/x-httpd-php </FilesMatch> Returns a generic "File not found" page <Files *.shtml> ForceType application/x-httpd-php </Files> <Files 404.shtml> ForceType application/x-httpd-php.php </Files> RemoveHandler .shtml AddType application/x-httpd-php .shtml AddType application/x-httpd-php .shtml PS. I won't be using bullet points in a post again!
rainborick msg:4435623 5:13 pm on Mar 31, 2012 (gmt 0)
You should be able to use something like: <!--#include virtual="header.php" --> in your SHTML files to include a PHP header without any additional magic in your .htaccess file. Darla839 msg:4436694 2:38 pm on Apr 3, 2012 (gmt 0)
Good grief! That was so easy, and did exactly what I wanted. Thanks! g1smd msg:4436718 3:31 pm on Apr 3, 2012 (gmt 0)
None of the redirect options you mentioned above could ever work. Redirects work only with incoming URL requests from outside the server not with internal filesystem requests. When a page does not exist it isn't the browser that is told to make a new request for the 404 page. When a page does not exist, the server internally looks for and then serves the file containing your "404 not found" error message page instead of the file that it could not find in the server filesystem.