Is it possible to redirect (via a Rewrite Cond?) users to another URL for help if an index.html or index.php file doesn't exist within their home directory?
Thanks Greg
Is it possible to redirect (via a Rewrite Cond?) users to another URL for help if an index.html or index.php file doesn't exist within their home directory?
Thanks Greg
You need to use the [L] flag.
http://httpd.apache.org/docs/2.2/rewrite/flags.html#flag_l
A similar case is illustrated here:
https://stackoverflow.com/questions/2118898/if-no-file-rewrite-url
The -f
mode of RewriteCond
can check for file existence. You can use this to test for a file's existence. For instance, if the user requests a directory that has no index, you can redirect them with something along these lines:
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME}/index\.(html|php) !-f
RewriteRule ^ http://example.com/something-blew-up.html [R=302]