i am trying to redirect user to external website using FallbackResource
when i am trying FallbackResource https://www.example.com
i am getting 500 error
.
But when i do something like FallbackResource /fallback.php
everything is fine.
How to make user redirect using FallbackResource?
You can't use an external URL with FallbackResource
. You can't externally redirect the request using FallbackResource
. As the docs state, this should be a local-url.
If you want to do this then use mod_rewrite instead. For example:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . https://www.example.com/ [R=302,L]
This gives you more control that FallbackResource
. You can set the 3xx status and you can choose to redirect requests that would otherwise map to a directory, which FallbackResource
would not (and often doesn't return a meaningful response for the user anyway).
The above 302 redirects any request, other than the document root (denoted by the regex .
) and that doesn't map to a file or directory to https://www.example.com/
.