There is a certain path http://site.ru/img/blalaala
, where blabla
is an unknown file and it is not on the server. Based on this, what needs to be written in .htaccess
so that when opening this path with an additional parameter \ and without blabla
did a certain php script open?
|
1 answer
You probably need something like this:
RewriteEngine On RewriteBase / RewriteRule ^img(/.*)?$ /404.html [L]
Here you can redirect from any address inside img
and from the img
to /404.html
.
If, however, it is necessary that redirection only works for files missing on the server, then the rule should be somewhat different:
RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^img(/.*)?$ /404.html [L]
|