Answer the question
In order to leave comments, you need to log in
How to redirect missing files/folders in mod_rewrite?
Good afternoon!
There is a site, for example, test.ru, available via http and https protocols , DocumentRoot is different
in the root of the https version, there is an admin folder , the point is that it is available via a secure protocol, but if any other file / folder from the https version is requested, a redirect is needed to the same file/folder in the http version
in the root of the https version I put .htaccess
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://%{HTTP_HOST }%{REQUEST_URI} [R=301,L]
the first condition is for missing files, the second one is for missing folders
, everything is fine, but there is a jamb - when I access the site's https root directly, I get 403: Forbidden, since there is no index file (nothing at all except the admin folder and the .htaccess file)
what to add to . htaccess, I can’t figure it out at all, only ideas come to mind to create index.php and already resolve the redirect in it, but it somehow looks wrong
Answer the question
In order to leave comments, you need to log in
You can check for the current state of HTTPS:RewriteCond %{HTTPS} !=on
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question