Re: htaccess file



On Sun, 30 Dec 2007, Barely Audible wrote:-

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^.*Ants.*$ [OR]
^ ^
Any real reason for those anchors since you're matching the entire
string?

RewriteCond %{HTTP_USER_AGENT} ^.*attach.*$ [OR]
^^
Try using NC,OR.

RewriteCond %{HTTP_USER_AGENT} ^.*BackWeb.*$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^.*Bandit.*$ [OR]

RewriteCond %{HTTP_USER_AGENT} ^.*Zeus.*$

And don't forget the [NC] at the end of this line.

RewriteRule ^.*$ http://www.use_a_normal_browser_to_view_the_jed_site_p
^^^^
Using ".*" does the same job

ages_please.com/ [L]

Try replacing the [L] with [NC,R=301,L]

The trouble is I seem to have done something wrong and I keep getting
the following error when accessing the web site....

Error 500

Any clues as to what I am doing wrong will be greatly appreciated...

There's something in your .htaccess file that the web server doesn't
understand. Posting the full file, rather than snippets, would be a good
start.

Anyway, this one works for me:

davjam@cobra-mk3:~> cat ~/public_html/new_dir/.htaccess
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} .*lynx.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*linx.* [NC]
RewriteRule .* http://www.google.com/ [NC,R=301,L]

This will redirect browsers those that identify themselves as Lynx or
Linx (a play on links), to Google while leaving others to go through to
the (blank) page. Here's the results of a quick telnet testing:

davjam@cobra-mk3:~> telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /~davjam/new_dir/ HTTP/1.0
User-Agent: Links

HTTP/1.1 200 OK
Date: Sun, 30 Dec 2007 18:22:02 GMT
Server: Apache/2.2.4 (Linux/SUSE)
X-Powered-By: PHP/5.2.5
Content-Length: 0
Connection: close
Content-Type: text/html

Connection closed by foreign host.
davjam@cobra-mk3:~> telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /~davjam/new_dir/ HTTP/1.0
User-Agent: Lynx

HTTP/1.1 301 Moved Permanently
Date: Sun, 30 Dec 2007 18:22:19 GMT
Server: Apache/2.2.4 (Linux/SUSE)
Location: http://www.google.com/
Content-Length: 309
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://www.google.com/";>here</a>.</p>
<hr>
<address>Apache/2.2.4 (Linux/SUSE) Server at davjam.org Port 80</address>
</body></html>
Connection closed by foreign host.

Alternatively, replace the 301 with a 302 for a temporary "moved"
response.


Regards,
David Bolt

--
www.davjam.org/lifetype/ www.distributed.net: OGR@100Mnodes, RC5-72@15Mkeys
SUSE 10.1 32bit | openSUSE 10.2 32bit | openSUSE 10.3 32bit | openSUSE 11.0a0
SUSE 10.1 64bit | openSUSE 10.2 64bit |
RISC OS 3.6 | TOS 4.02 | openSUSE 10.3 PPC |RISC OS 3.11
.



Relevant Pages

  • TCP Socket Question
    ... Earlier today in my C++ class, our instructor introduced us to sockets. ... string then closes the connection. ... This server and has been used by 1 users. ...
    (comp.unix.programmer)
  • Mysql broker since FreeBSD update
    ... I updated a FreeBSD 5.2.1 server to HEAD. ... -bash-2.05b$ telnet localhost 3306 ... Connection closed by foreign host. ...
    (comp.unix.bsd.freebsd.misc)
  • Re: leafnode and host name
    ... >> I asume that you have to autenticate on the server smtp.freeserve.com. ... you send a message to e.g. houghi at hotmail.com ... houghipenne: telnet localhost 25 ... Connection closed by foreign host. ...
    (alt.os.linux.suse)
  • Re: fetchmail problem
    ... >>seems that it got me little further, but got into new error messages. ... you should not get a connection at all. ... >exim4, sendmail, postfix, masqmail... ... I did telnet localhost 25 ...
    (Debian-User)
  • Re: [opensuse] mod_perl in OpenSuse 10.2
    ... Options +ExecCGI -Includes ... SetHandler perl-script ... Connection: close ...
    (SuSE)