I want to every request for any file or directory on my server to be redirected to a specified file on the server.
The file I want everything to redirect to is: "/var/www/test.php".
I think this might be possible with htaccess files but I'm unsure, can anyone help?
Redirect Every Request to Page
Moderator: General Moderators
Re: Redirect Every Request to Page
You should be able to do it with mod_rewrite.
i'm not 100% sure this will work but you can give it a go in your .htaccess
RewriteEngine On
RewriteBase /
RewriteOptions MaxRedirects=1
RewriteRule ^.*$ test.php [NC,L]
i'm not 100% sure this will work but you can give it a go in your .htaccess
RewriteEngine On
RewriteBase /
RewriteOptions MaxRedirects=1
RewriteRule ^.*$ test.php [NC,L]
Re: Redirect Every Request to Page
Additionally, if you want to know WHERE they tried to browse to:theserve wrote:You should be able to do it with mod_rewrite.
i'm not 100% sure this will work but you can give it a go in your .htaccess
RewriteEngine On
RewriteBase /
RewriteOptions MaxRedirects=1
RewriteRule ^.*$ test.php [NC,L]
Code: Select all
RewriteEngine On
RewriteBase /
RewriteOptions MaxRedirects=1
RewriteRule ^(.*)$ /test.php?path=$1 [NC,L]HOWEVER, this will do EVERYTHING, including images, css, js... If you want to be able to still have those called, then do something like:
Code: Select all
RewriteEngine On
RewriteBase /
RewriteOptions MaxRedirects=1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /test.php?path=$1 [NC,L]-Greg