Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
How can I strip clean a referring URL?
Old 12-17-2006, 10:50 PM How can I strip clean a referring URL?
Junior Talker

Posts: 2
Trades: 0
Hi

I'm a programming/scripting nitwit looking for some help. I would like to show the 'domain' part of referring URLs on a web page that I'm working on.

So if someone is referred by..

http://www.webmaster-talk.com/newthr...ostthread&f=79

.. then I'd like to just show www.webmaster-talk.com somewhere on that page.

Not sure if this is at all possible.. But any code suggestions will be much appreciated!
Netherland is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-18-2006, 12:27 AM Re: How can I strip clean a referring URL?
stOx's Avatar
Machine

Latest Blog Post:
Worlds Smallest Car - Peel P50
Posts: 2,111
Name: Matt. (>',')>
Location: London, England.
Trades: 0
you could use str_replace() on the http:// and explode() on the /

Though im fairly sure there is a function to get just the domain from the referring url.

edit: Sorry, I assumed it was in php.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
stOx is offline
Reply With Quote
View Public Profile Visit stOx's homepage!
 
Old 12-18-2006, 04:23 AM Re: How can I strip clean a referring URL?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
we'll just do the same in asp (VbScript) then

replace() & split()

Code:
function referer_host()
dim url
dim url_parts

url = replace(request.servervariables("HTTP_REFERER"),"http://","")
url_parts = split(url,"/")
referer_host = url_parts(0)
end function
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-18-2006, 08:52 AM Re: How can I strip clean a referring URL?
Junior Talker

Posts: 2
Trades: 0
Quote:
Originally Posted by chrishirst View Post
we'll just do the same in asp (VbScript) then

replace() & split()

Code:
function referer_host()
dim url
dim url_parts
 
url = replace(request.servervariables("HTTP_REFERER"),"http://","")
url_parts = split(url,"/")
referer_host = url_parts(0)
end function
Yep, this really does work! Nice and clean. Thanks so much, Chris!


And thanks to you too, stOx. I will certainly document your suggestion for future reference, in case I ever start using PHP.

------
Alex

Last edited by Netherland; 12-18-2006 at 08:54 AM..
Netherland is offline
Reply With Quote
View Public Profile
 
Old 12-18-2006, 11:21 AM Re: How can I strip clean a referring URL?
kline11's Avatar
SearchBliss Web Tools

Posts: 1,726
Name: John
Location: USA
Trades: 0
Can't you just use request.servervariables("URL") instead of request.servervariables("HTTP_REFERER") to get the base URL?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
kline11 is offline
Reply With Quote
View Public Profile
 
Old 12-18-2006, 01:24 PM Re: How can I strip clean a referring URL?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
servervariables("URL") returns the relative URL of the current page not the referering URL
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-18-2006, 02:33 PM Re: How can I strip clean a referring URL?
kline11's Avatar
SearchBliss Web Tools

Posts: 1,726
Name: John
Location: USA
Trades: 0
Duh...what was I thinking?!? Now I feel stupid. I better write some script to better myself worth. Sorry.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
kline11 is offline
Reply With Quote
View Public Profile
 
Old 12-19-2006, 08:30 AM Re: How can I strip clean a referring URL?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0


happens to us all occasionally
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-19-2006, 12:30 PM Re: How can I strip clean a referring URL?
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
Don't feel bad, kline. About 5 years ago, I did the same thing. Took me over 4 hours to figure it out, too.

As long as you learn from it, and don't repeat the mistake, it's not a stupid mistake. It's part of the learning curve.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 12-19-2006, 04:01 PM Re: How can I strip clean a referring URL?
kline11's Avatar
SearchBliss Web Tools

Posts: 1,726
Name: John
Location: USA
Trades: 0
Thanks all. The problem is I'm not a newbie to ASP. I've been writing VB for about 6 years. This is why I feel stupid. Well, at any rate, I'm over it now. Thanks again.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
kline11 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How can I strip clean a referring URL?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.24436 seconds with 12 queries