I've got a webapp that must process the URI to locate if your page is available inside a database. I've not a problem pointing the URI towards the application with .htaccess:
Options +FollowSymlinks RewriteEngine on RewriteCond % !-f RewriteRule ^(.*)$ index.php?p=$1 [NC]
My problem is when the page doesn't exist, I don't want to utilize a custom 404 handler designed in PHP, I'd like do show the default Apache 404 page. Can there be any method of getting PHP to hands execution to Apache if this has determined the page doesn't exist?
Refer to this as function:
The only real way possible I know of for that above scenario would be to have this kind of php code inside your
<?php if (pageNotInDatabase)
After which slightly modify your .htaccess such as this:
Options +FollowSymlinks -MultiViews RewriteEngine on RewriteCond % !-f RewriteCond % !notFound=1 [NC] RewriteRule ^(.*)$ index.php?p=$1 [NC,L,QSA]
This way Apache can have default 404 page with this special situation due to extra query parameter
?notFound=1 added from php code along with the negative check for the similar inshtaccess page it won't be submitted to index.php the next time.
PS: A URI like
/foo, otherwise present in database will end up
/foo?notFound=1 within the browser.
I do not think you are able to "hands it back" to Apache, however, you can send the right HTTP header after which clearly incorporate your 404 file such as this:
if( !$is available )
Offhand, the easiest way I'm able to think to get this done is always to set a 404 header inside your script, something similar to this:
<?php // file: index.php if( !(/* some logic to ensure that page is available */) ) // the application code here...