Using the following as a 503 forwarder on a wordpress website. For some reason it words for foo.com/xyz, but not foo.com itself. Any thoughts?
.htaccess file:
ErrorDocument 503 /rdi/index.php
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /rdi/index.php [R=503,L]
Any url that ends with a
/
requests a folder, and any url that does not end on a/
requests a file. When you requesthttp://example.com
, you actually requesthttp://example.com/
, the document root ofexample.com
. Your document root is obviously an existing folder, since otherwise you wouldn’t be able to run a site at all.You are using the following rule:
The second condition says: “If the requested filename is not a directory”. Your document root is a directory, so that condition is false. It won’t rewrite.
You can use the following rule:
What will this do? If you request
http://example.com
, the first condition will match, the second will be ignored because of the[OR]
flag, and the third condition will be true. If you requesthttp://example.com/rdi/
, the first condition will be false and the second condition will be false and so the rule will not be used. If you requesthttp://example.com/asdfasdf/
, the first condition will be false, but due to the[OR]
flag it will try the second condition, which is true. Then it checks the third condition which is true, which will then rewrite the request.