Answer the question
In order to leave comments, you need to log in
How to redirect Apache before it gives a 404 error?
How to redirect Apache to another file using mod_rewrite without declaring a 404 error?
Now .htaccess contains a line like ErrorPage 404 /index.php
Apache processes the error, writes about it to the log and passes control to index.php, which processes the request.
.htaccess content
AddDefaultCharset UTF-8
Options +FollowSymLinks +ExecCGI
ErrorDocument 404 /index.php
RewriteEngine On
#Hides backend and its static content from all domains except 1
RewriteCond %{REQUEST_URI} !^/index.php$ [NC]
RewriteCond %{ REQUEST_FILENAME} -f
RewriteCond %{HTTP_HOST} !^.*$
RewriteRule ^(.*)$ - [R=404,L]
#No script name
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
Answer the question
In order to leave comments, you need to log in
Depending on what condition. Here is an example:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /file_to_rewrite.php [L]
</IfModule>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question