EN
apache2 / .htaccess - run php script if file does not exist
9
points
In this short article we would like to show you how configure .htaccess
to execute some alernative script when file indicated in URL doesn't exist on apache2 server.
Quick solution (.htaccess
file):
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ /script.php [L]
Β
Web site details
Web site structure:
/var/www/html
βββ .htaccess
βββ file1.txt
βββ file2.txt
βββ script.php
|
Screenshots:Β
Β