You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Aaron Gray <aa...@gmail.com> on 2011/12/21 16:01:53 UTC

[users@httpd] Re: .htaccess help - restricting access to certain REMOTE_host's and redirecting others to /index.html

On 19 December 2011 14:24, Aaron Gray <aa...@gmail.com> wrote:

> Hi,
>
> I am really having problems understand and getting .htaccess mod_rewrite's
> to work.
>
> What I want is a site that rewrites any traffic that is not from a set
> number of REMOTE_HOST's or in a set of certain files to always be
> redirected to /index.html, whether they are in a subdirectory or
> subdirectory or another file in root.
>
>
Okay here's the solution :-

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /

RewriteCond %{REMOTE_HOST} =xxx.yyy.co.uk [OR]
RewriteCond %{REMOTE_HOST} =zzz.yyy.co.uk
RewriteRule .* - [L]

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.html [L]

</IfModule>

Seems to work through tests, but not sure why I need the '-d' rather than a
'!-d' ?

Aaron