Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 05-18-2005, 01:37 AM   #1 (permalink)
elspeth
Registered User
 
Join Date: May 2005
Posts: 4
elspeth is on a distinguished road
Question Htaccess problems

I'm having a problem with my htaccess file and I hope someone can help.
I initally had a file that stopped hotlinking and a loaded a 404 error page. But when I updated my site and removed a lot of the images that originally had been hotlinked, I thought I could also remove the hotlink codes in my .htaccess file. But now I'm being hotlinked yet again.
So I tried adding the same codes to the file again (saved as .txt file and uploaded using ascii and then renamed file to .htaccess) ... my 404 page loaded fine but the hotlinked images are still loading.
I contacted my provider and they sent me codes to use:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ - [F]

I uploaded this to my dir folder (after I had replaced "yourdomain.com" with my own info)and it wiped my site! So I moved it to the image subfolder where it successfully stopped the hotlinking, but also stopped my own images from showing. Not really what I was after.
So my question (sorry it's so long winded!) is how do I create a .htaccess code that will include both a 404 and stop hotlinking and actually work!!
I have several sub-domains on my domain and img folders in those sub-domains.
I run WinXP and I've been using both WS_FTP and FTP Navigator to upload files... if that is of any help.
elspeth is offline   Reply With Quote
Old 05-18-2005, 08:17 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
i'm not sure exactly what the problem is, but have you taken a look at the article here at code newbie regarding hotlinking?

http://html.codenewbie.com/articles/...on-Page_1.html

maybe that will help.
__________________
Mike
sde is offline   Reply With Quote
Old 05-18-2005, 11:54 AM   #3 (permalink)
elspeth
Registered User
 
Join Date: May 2005
Posts: 4
elspeth is on a distinguished road
Okay the problem is my hotlinked images are still showing instead of a little red cross.

This is what I've written in my htaccess file:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ - [F]

ErrorDocument 404 http://www.mysite.com/404.html

Like I said previously the 404 page loads just fine, but any hotlinked images from my site on a forum are still visible instead of a little red x. Is the code wrong? I've emptied my internet cache and still no luck. So what could be wrong?
And yes I have had a look at the page you mentioned, but it doesn't give me any information that helps.
elspeth is offline   Reply With Quote
Old 05-18-2005, 01:44 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
well you have nothing in that code that is re-writing. it is just faling the pag i think.

i just verified that this code works here on code newbie.
Code:
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(.*)?mysite\.com [NC]
RewriteCond %{REQUEST_URI} !^(.*)/nohotlinking.gif [NC]
RewriteRule ^(.*)\.(gif|jpg)$ http://mysite.com/images/nohotlinking.gif [R]
of course ou will need a nohotlinking.gif image on your site, .. and change the name appropriately.
__________________
Mike
sde is offline   Reply With Quote
Old 05-18-2005, 11:14 PM   #5 (permalink)
elspeth
Registered User
 
Join Date: May 2005
Posts: 4
elspeth is on a distinguished road
Nope... that didn't work either! My images are still showing up instead of my newly created hotlinking gif.
Do you have any other ideas I could try?
elspeth is offline   Reply With Quote
Old 05-19-2005, 06:54 AM   #6 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
all i can tell you is that works perfectly here.

how exactly are you testing it? you do know that it's only going to work if the referer is not your own domain, nor blank.

i.e. http://subaruboxer.com/test.html

in that example, you can see the link in your status bar is our news gif, .. but when you click on it, it will give you the hotlink gif.
__________________
Mike
sde is offline   Reply With Quote
Old 05-19-2005, 07:02 AM   #7 (permalink)
elspeth
Registered User
 
Join Date: May 2005
Posts: 4
elspeth is on a distinguished road
There are several forums that have linked to images on my site, so once I'd uploaded the htaccess file to my main directory, I checked the forum page to see if my images were still loading and they were.
I've tried uploading the htaccess file in my main dir folder... didn't work. I tried it in my various sub folders and deleted it from my main dir folder... still didn't work.
I'm at the stage where I've almost given up.... so until I can figure it out I have changed my sub folders names and that's stopped the problem... temporarily anyway.
I'd still appreciate any other ideas though. Thanks for your help so far.
elspeth is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
cin.getline problems mconn86 Standard C, C++ 5 04-14-2005 01:02 PM
Problems debugging visual c++ in vs.net 2003 Engineer MS Technologies ( ASP, VB, C#, .NET ) 2 07-20-2004 12:19 PM
no dial tone problems fabiopao Linux / BSD / OS X 4 02-23-2003 10:51 AM
I have problems... anon Lounge 4 01-12-2003 07:47 PM
htaccess Admin Feedback 0 07-09-2002 10:48 AM


All times are GMT -8. The time now is 02:07 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting