Welcome to HostingForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

A good article about .htaccess files

 
   Web Hosting Problem Solving Community! (Home) -> Webmaster RSS
Next:  keep track of exe downloads  
Author Message
konradp

External


Since: Dec 29, 2004
Posts: 8



(Msg. 1) Posted: Thu Mar 03, 2005 11:35 am
Post subject: A good article about .htaccess files
Archived from groups: alt>www>webmaster (more info?)

Hello everyone, forgive me my English.

I try to find a good tutorial\article about writing htacces file, but I
failed. I found a lot of websites talking about how to solve a given
problem, but nothing about what those commands mean. Do you know something?

Right now I want to exclude certain website from reading images from my
own websites (I already wrote about it), can someone tell me if this is
correct (in .htaccess file):

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} .*jpg$|.*gif$|.*png$ [NC]
RewriteCond %{HTTP_REFERER} badsite1\.com [NC]
RewriteCond %{HTTP_REFERER} badsite2\.com [NC]
RewriteRule (.*) /goaway.html

What I want is that the badsite1.com and badsite2.com can't get my
images, instead they will be redirected to the goaway.html file, which
would be empty, is that ok?

And what about badsite1.com/subpage, will this work too, or should I
rather use something like:
RewriteCond %{HTTP_REFERER} badsite1\..*com [NC]

that is, any website url beginning with badsite1, is that correct?

I'd be very gratefull for your help.

--
Konrad Papala
www.konradp.com

 >> Stay informed about: A good article about .htaccess files 
Back to top
Login to vote
comments

External


Since: Sep 14, 2004
Posts: 1625



(Msg. 2) Posted: Thu Mar 03, 2005 1:35 pm
Post subject: Re: A good article about .htaccess files [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Once upon a time, far far away Konrad <konradp.RemoveThis@_removeit_o2.pl>
spluttered

 >I try to find a good tutorial\article about writing htacces file, but I
 >failed. I found a lot of websites talking about how to solve a given
 >problem, but nothing about what those commands mean.

Try <a style='text-decoration: underline;' href="http://httpd.apache.org/docs" target="_blank">http://httpd.apache.org/docs</a>

Matt

--
If your encyclopaedia doesn't list "widget glass", you're reading the wrong encyclopaedia.
The Probert Encyclopaedia. Its not the same.
<a style='text-decoration: underline;' href="http://www.probertencyclopaedia.com" target="_blank">http://www.probertencyclopaedia.com</a><!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: A good article about .htaccess files 
Back to top
Login to vote
Toby Inkster

External


Since: Mar 02, 2005
Posts: 44



(Msg. 3) Posted: Thu Mar 03, 2005 3:35 pm
Post subject: Re: A good article about .htaccess files [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Konrad wrote:

 > RewriteCond %{HTTP_REFERER} badsite1\..*com [NC]
 > that is, any website url beginning with badsite1, is that correct?

No, way off.

"badsite1\..*.com" means addresses that start with "badsite1." and then
at least one more character and then "com".

So it won't even match "badsite1.com".

You want:

  badsite1\.com/.*

but that isn't needed, because RewriteCond looks at substrings, so the
original "badsite1\.com" will do.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ <a style='text-decoration: underline;' href="http://tobyinkster.co.uk/contact" target="_blank">http://tobyinkster.co.uk/contact</a><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: A good article about .htaccess files 
Back to top
Login to vote
konradp

External


Since: Dec 29, 2004
Posts: 8



(Msg. 4) Posted: Thu Mar 03, 2005 3:35 pm
Post subject: Re: A good article about .htaccess files [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Konrad wrote:

 > Hello everyone, forgive me my English.
 >
 > I try to find a good tutorial\article about writing htacces file, but I
 > failed. I found a lot of websites talking about how to solve a given
 > problem, but nothing about what those commands mean. Do you know something?
 >
 > Right now I want to exclude certain website from reading images from my
 > own websites (I already wrote about it), can someone tell me if this is
 > correct (in .htaccess file):
 >
 > RewriteEngine On
 > RewriteCond %{REQUEST_FILENAME} .*jpg$|.*gif$|.*png$ [NC]
 > RewriteCond %{HTTP_REFERER} badsite1\.com [NC]
 > RewriteCond %{HTTP_REFERER} badsite2\.com [NC]
 > RewriteRule (.*) /goaway.html
 >
 > What I want is that the badsite1.com and badsite2.com can't get my
 > images, instead they will be redirected to the goaway.html file, which
 > would be empty, is that ok?
 >
 > And what about badsite1.com/subpage, will this work too, or should I
 > rather use something like:
 > RewriteCond %{HTTP_REFERER} badsite1\..*com [NC]
 >
 > that is, any website url beginning with badsite1, is that correct?
 >
 > I'd be very gratefull for your help.
 >

Thank you both!

--
Konrad Papala
<a style='text-decoration: underline;' href="http://www.konradp.com" target="_blank">www.konradp.com</a><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: A good article about .htaccess files 
Back to top
Login to vote
anonymous3

External


Since: Apr 03, 2004
Posts: 146



(Msg. 5) Posted: Thu Mar 03, 2005 3:35 pm
Post subject: Re: A good article about .htaccess files [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Back to top
Login to vote
Toby Inkster

External


Since: Mar 02, 2005
Posts: 44



(Msg. 6) Posted: Thu Mar 03, 2005 6:35 pm
Post subject: Re: A good article about .htaccess files [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Richard wrote:

 > Most confusing. You first say it's wrong, then show what's right, then say
 > what's wrong is ok because of the other command.

No. The OP gave two examples.

The frst was sufficient for his needs.

The second example he gave was an attempt to improve what he had, but it
waouldn't have worked.

So I corrected the second example, but mentioned that the first would do
what he needed.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ <a style='text-decoration: underline;' href="http://tobyinkster.co.uk/contact" target="_blank">http://tobyinkster.co.uk/contact</a><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: A good article about .htaccess files 
Back to top
Login to vote
Toby Inkster

External


Since: Mar 02, 2005
Posts: 44



(Msg. 7) Posted: Thu Mar 03, 2005 6:35 pm
Post subject: Re: A good article about .htaccess files [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Richard wrote:

 > My idea though, would be to redirect the site to whitehousesex.com

Theoretically, how would you do that then?

I would include this on my page:

  <img src="http://somestuff.batcave.net/somefile.gif" alt="Some file">

what would you do your end? I'd really like to know how you think you're
going to redirect my visitors to that website.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ <a style='text-decoration: underline;' href="http://tobyinkster.co.uk/contact" target="_blank">http://tobyinkster.co.uk/contact</a><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: A good article about .htaccess files 
Back to top
Login to vote
konradp

External


Since: Dec 29, 2004
Posts: 8



(Msg. 8) Posted: Fri Mar 04, 2005 9:35 am
Post subject: Re: A good article about .htaccess files [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Konrad wrote:

 > Hello everyone, forgive me my English.
 >
 > I try to find a good tutorial\article about writing htacces file, but I
 > failed. I found a lot of websites talking about how to solve a given
 > problem, but nothing about what those commands mean. Do you know something?
 >
 > Right now I want to exclude certain website from reading images from my
 > own websites (I already wrote about it), can someone tell me if this is
 > correct (in .htaccess file):
 >
 > RewriteEngine On
 > RewriteCond %{REQUEST_FILENAME} .*jpg$|.*gif$|.*png$ [NC]
 > RewriteCond %{HTTP_REFERER} badsite1\.com [NC]
 > RewriteCond %{HTTP_REFERER} badsite2\.com [NC]
 > RewriteRule (.*) /goaway.html
 >
 > What I want is that the badsite1.com and badsite2.com can't get my
 > images, instead they will be redirected to the goaway.html file, which
 > would be empty, is that ok?
 >
 > And what about badsite1.com/subpage, will this work too, or should I
 > rather use something like:
 > RewriteCond %{HTTP_REFERER} badsite1\..*com [NC]
 >
 > that is, any website url beginning with badsite1, is that correct?
 >
 > I'd be very gratefull for your help.
 >

I finally found out how to do that. For everybody interested:

The above aproach could not work, because the default operator between
RewriteCond's is AND, and what we need is OR. So here it is:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} .*jpg$|.*gif$|.*png$ [NC]
RewriteCond %{HTTP_REFERER} badsite1\.net [NC,OR]
RewriteCond %{HTTP_REFERER} badsite2\.org [NC,OR]
RewriteCond %{HTTP_REFERER} badsite3\.org [NC]
RewriteRule .* - [F]

Now, if any above website try to load our images, they fail ([F]).

Of course, if we want to exclude every referer except for choosen ones
this is better:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} .*jpg$|.*gif$|.*png$ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !ok_site1\.com [NC]
RewriteCond %{HTTP_REFERER} !ok_site2\.com [NC]
RewriteRule .* - [F]

Now every page except for those two, as well as an empty referer, will fail.

To send another image, instead of FAIL, we can use this:
RewriteRule .* other_image.gif

By the way - I was testing also:
RewriteRule .* /other_image.gif

But it did not work.

Thanks for your help.

--
Konrad Papala
<a style='text-decoration: underline;' href="http://www.konradp.com" target="_blank">www.konradp.com</a><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: A good article about .htaccess files 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Anyone Know of a Good Article about Forms Round Tripping w.. - Anyone Know of a Good Article about Forms Round Tripping with Post and PHP Processing?

Looking for good PHP program to upload Word/Excel Files - I'm looking for a good and free PHP program that my users can upload Word/Excel files to my website. Any suggestions would be greatly appreciated.

How to set files permissions with .htaccess - Hi all, When I upload a file on my server with a cms, by default the permissions on this file is set to "440", which mean that the file cannot be readable in a browser. Do someone know a way to automatically set (chmod) the files's permissions...

clashing htaccess files question - I have been using a htaccess file to enable people to access a folder to see a listing of files for download. The htaccess file is inside this folder and just contains the line Options Indexes. I have now also started using a htaccess file in the main...

.htaccess prevents itself from being viewed but not "sess*.. - <Directory /> Options -Indexes </Directory> <Files ~ "^\.ht"> order allow,deny deny from all </Files> <Files ~ "^sess[a-zA-Z0-9\-_\.]*$"> order allow,deny deny from all </Files>...
   Web Hosting Problem Solving Community! (Home) -> Webmaster All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]