Hello! I want that my server makes a rewrite to the file 'handler.php' if a not existing file is called, i.e. [domain.com...] With the .htaccess code below it works generally but if the user calls the domain without the default file index.php the user is also rewrited because the apache obviously thinks this file name (without content) is also not existing. So, how must the code look like that it knows the domain entered without a file name is an exeption? Best regards Marc rewriteEngine on rewriteBase / rewriteCond %{REQUEST_FILENAME} !-f rewriteRule ^.* handler.php [L]
The easiest way and the way I normally do it is to use index.php as the handler rather than in this case handler.php, you can do it with mod_rewrite but really I suggest renaming the file.
Okay. But then I have to do a lot of changes in the index.php code. Isn't there a way to recognize a domain request (without a file name) and handle it directly in the .htaccess? Marc
RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]+\ /\ HTTP/ [OR] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule .* handler.php Code (markup): Should do the tick.
Sorry, but it does not work. Calling the domain without the default index.php will also rewrite it. Marc
Give the following a shot think this is what you're after: RewriteEngine on RewriteBase / RewriteCond %{THE_REQUEST} !^[A-Z]+\ /\ HTTP/ RewriteCond %{REQUEST_FILENAME} !-f RewriteRule .* handler.php Code (markup):
users who call a not existing file should be rewritten to handler.php. That's all. My in my first post introduced code works so far but does also rewrite users who call the domain without the default file (index.php) what of course the most users do not enter.
Thank you, Romika! I will keep it for further problems. I hope so far in the future that computers are programming our servers. Marc