Welcome Guest, Not a member yet? Register   Sign In
404_error.php breaks on php code (in specific cases)
#1

[eluser]jant90[/eluser]
When I try to a non-existing page CodeIgniter opens 404_error.php for me (which I styled to my liking), and where I added some PHP code. This is great except that it doesn't work fully as expected.

When I load www.mydomain.nl/existingcontroller/nonexistingfunction for example the error document loads as expected but when I load www.mydomain.nl/nonexistingcontroller the 404 page breaks on the first PHP code.

In my case this PHP code is in the head of the document at the following line:
Code:
<link rel="stylesheet" href="<?=base_url();?>includes/style.css" type="text/css" />

So all I get to see is an empty page, because after '<link rel="stylesheet" href="' nothing is loaded. IE shows an http 500 error.

When I add
Code:
ErrorDocument 500 /index.php
to my htaccess I get to see the homepage with the incorrect link, but this is not what I want. I just want the error page to be displayed.

I think this problem might have something to do with my htaccess file as I remove www and index.php from my urls. My htaccess page looks like this, I got this htaccess from this forum and made a few changes:
Code:
Options -Indexes

Options +FollowSymLinks

<IfModule mod_rewrite.c>
    RewriteEngine on

    RewriteCond %{HTTP_HOST} ^www\.mydomain\.nl$ [NC]
    RewriteRule ^(.*)$ http://mydomain.nl/$1 [L,R=301]

    RewriteCond %{REQUEST_FILENAME} !index.php

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>


How do I get the full 404_error.php (including the dynamic php code) to load even when I call for a non existing controller?

Thanks in advance,
Jan




Theme © iAndrew 2016 - Forum software by © MyBB