04-08-2004, 18:34
|
#1
|
|
Inactive
Join Date: Jan 2004
Location: Swansea
Posts: 1,376
|
Website Help (Advance)
I am in need of a STRANGE request
If a website (say www.url1.com ) links to a page, say help.htm ( www.url1.com/help.htm) how can I get a script, code or HTACCES to allow this example...
www.url1.com/help.htm shows a Page.... But if any other site (say www.url2.com) links to www.url1.com/help.htm another page Displays... (Maybe like a "No Hotlinking or Custom NO Page Found)
I dont want a Error 404 thing in HTACCES, but a way to moniter where a link came from & display either the first Page or Second... But both have the same HTML address ( www.url1.com/help.htm) & both editable HTML's
TIA..
|
|
|
04-08-2004, 18:37
|
#2
|
|
Inactive
Join Date: Jul 2003
Location: Eglinton, Co. Derry
Posts: 7,640
|
Re: Website Help (Advance)
|
|
|
05-08-2004, 14:03
|
#3
|
|
Inactive
Join Date: Jan 2004
Location: Swansea
Posts: 1,376
|
Re: Website Help (Advance)
Quote:
|
Originally Posted by Bifta
|
Thanks for that Bifta..
But I think that is for JPG or GIFS only ...... I wanted one that would work on HTML's or PHP
Same idea as Image Hotlinking, but if anyone typed the URL in the Address bar or click on a link "Out Side" my site, then it will display another page. But if the link came from my chosen website URL it would allow..
Any Ideas guys?
|
|
|
05-08-2004, 14:06
|
#4
|
|
Inactive
Join Date: Jul 2003
Location: Eglinton, Co. Derry
Posts: 7,640
|
Re: Website Help (Advance)
you could set up a php script (or ASP, even javascript) to read the document referrer and redirect them to a different page it the referrer doesn't contain your domain name.
|
|
|
05-08-2004, 14:33
|
#5
|
|
Inactive
Join Date: Jul 2003
Location: Eglinton, Co. Derry
Posts: 7,640
|
Re: Website Help (Advance)
You can try this in each of your documents.
Code:
<script language="javascript">
if {document.referrer.indexOf("website.com") == -1}
window.location = "http://redirecturlinhere";
</script>
|
|
|
05-08-2004, 15:52
|
#6
|
|
Inactive
Join Date: Nov 2003
Location: Leeds - the dog house
Age: 49
Services: Email me for a current price list
Posts: 8,270
|
Re: Website Help (Advance)
Correct way is to use mod_rewrite to check the referrer and redirect to your site's main page if the referrer is not your site. The guide for Apache 2 is here:
http://httpd.apache.org/docs-2.0/misc/rewriteguide.html
I don't think mod_rewrite is part of the default build though.
|
|
|
05-08-2004, 16:12
|
#7
|
|
Inactive
Join Date: Jan 2004
Location: Swansea
Posts: 1,376
|
Re: Website Help (Advance)
Quote:
|
Originally Posted by greencreeper
Correct way is to use mod_rewrite to check the referrer and redirect to your site's main page if the referrer is not your site. The guide for Apache 2 is here:
http://httpd.apache.org/docs-2.0/misc/rewriteguide.html
I don't think mod_rewrite is part of the default build though.
|
 My Brain HURTS LOL
So much info...
Can you post what I need to type ? & where to stick it (No NOT that PLACE  )
If Referal comes from www.suzip.co.uk ALLOW to URL1.com if NOT off www.suzip.co.uk send to url2.com
Thanks
|
|
|
05-08-2004, 16:14
|
#8
|
|
Inactive
Join Date: Jul 2003
Location: Eglinton, Co. Derry
Posts: 7,640
|
Re: Website Help (Advance)
Code:
<script language="javascript">
if {document.referrer.indexOf("suzip.co.uk") == -1}
window.location = "url2.com";
</script>
Stick it in your <head> tags.
|
|
|
05-08-2004, 16:38
|
#9
|
|
Inactive
Join Date: Jul 2003
Location: Eglinton, Co. Derry
Posts: 7,640
|
Re: Website Help (Advance)
However .. i've just retested it and it doesn't work  I'll find something a bit more useful. The trouble is you need to strip out everything after the the final / for the referrer so it's not the most elegant bit of code.
Try putting this in your .htaccess file
RewriteEngine On RewriteCond %{HTTP_REFERER} !.*suzip.co.uk.* [NC]
RewriteCond %{HTTP_REFERER} !.*suzip.co.uk.* [NC]
RewriteRule /* http://whereveryouwanttoredirectpeopleto.com/ [R,L]
|
|
|
05-08-2004, 17:42
|
#10
|
|
Inactive
Join Date: Nov 2003
Location: Leeds - the dog house
Age: 49
Services: Email me for a current price list
Posts: 8,270
|
Re: Website Help (Advance)
Quote:
|
Originally Posted by JediMaster
 My Brain HURTS LOL
So much info...
Can you post what I need to type ? & where to stick it (No NOT that PLACE  )
If Referal comes from www.suzip.co.uk ALLOW to URL1.com if NOT off www.suzip.co.uk send to url2.com
|
It is a very powerful, and hence complex, piece of software, plus it makes heavy use of regular expressions, which is a language in itself.
Bifta's post looks about right. Like I said in my PM, my encounters with rewrite rules have been few and traumatic  I tend to look for similar examples and build the rules from them, testing as I go.
You might have to escape the . in the URL's - \.
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 23:56.
|