Forum Moderators: mack
I was thinking of redirecting all requests from Mozilla agents to a page explaining that the site reopens on Nov 1st. This way Googlebot and the major search engines would still have access.
I tried this with .htaccess:
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^Mozilla
RewriteRule /*$ [mydomain.com...] [R,L]
But this caused the server to break down (maybe an endless loop) and I couldn't even access it via FTP for one or two hours.
For clarity I'm including the complete .htaccess file (well a shortened version actually):
-----------------------------------------------------------
<Files .htaccess>
order allow,deny
deny from all
</Files>
order allow,deny
allow from all
deny from 213.120.138
deny from ............ many denied IP numbers here
SetEnvIfNoCase User-Agent "Indy Library" getout
SetEnvIfNoCase User-Agent ^.*Demon getout
SetEnvIfNoCase User-Agent ....... long list with agents here
<Limit GET POST>
Order Allow,Deny
Allow from all
Deny from env=getout
</Limit>
Options -Indexes
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://216\.239.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://images\.google.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www\.google\..*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://babel\.altavista\..*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://world\.altavista\.com.*$ [NC]
RewriteRule \.(jpg¦JPG)$ [mydomain.com...] [R,L]
RewriteCond %{HTTP_USER_AGENT} ^Mozilla
RewriteRule /*$ [mydomain.com...] [R,L]
Yes, you need to take steps to prevent an infinite loop of redirection.
For a single "Come back soon" page and nothing else, you could use:
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^Mozilla.+
RewriteRule !^temp_closed\.htm$ temp_closed.htm$ [R,L]
Which reads, "If user-agent is Mozilla AND NOT requesting temp_closed, redirect to temp_closed."
If you need to display the page plus a few graphics and maybe include an external JavaScript, you could
use the form:
RewriteCond %{HTTP_USER_AGENT} ^Mozilla.+
RewriteCond %{REQUEST_URI} !^temp_closed\.htm$
RewriteCond %{REQUEST_URI} !^detour\.gif$
RewriteCond %{REQUEST_URI} !^beback\.js$
RewriteRule .* temp_closed\.htm [R,L]
The above is for per-directory .htaccess use. If you do this in httpd.conf, you'll need to add leading slashes to the paths.
Jim
<edit> typo </edit>
[edited by: jdMorgan at 4:03 pm (utc) on Oct. 25, 2002]
RewriteRule !^temp_closed\.htm$ temp_closed.htm$ [R,L]
Thanks - it worked for me when I changed the line to:
RewriteRule !^temp_closed\.htm$ [mydomain.com...] [R,L]
In other words I had to specify the full URL.
RewriteRule !^temp_closed\.htm$ temp_closed.htm$ [R,L]RewriteRule .* temp_closed\.htm [R,L]
Ack! Sorry - I should have fixed those typos, too! Glad you got it working...
RewriteRule .* /temp_closed\.htm [R,L]
RewriteRule !^temp_closed\.htm$ /temp_closed.htm$ [R,L]
(Forgot the leading slashes)
You shouldn't have to put the full "http://www.yoursite.com" in there unless you want an off-site redirect. Leaving it out makes your rules more portable in case you change domains or want to use them on another domain.
Jim