Getting the domain name

Hello,

We have a fairly simple redirect script a url is entered, and even tho there are 
directions to not enter the "http://www" sometimes we get it or "http://"... 
what is the simplest method to extract just the domain name if a 
"http://www.somedomain_name.com" or "http://somedomain_name.com" is enter so we 
can extract just the "somedomain_name.com"

thx's


-- 
Mike<mickalo>Blezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
http://www.thunder-rain.com
Web Hosting
http://www.justlightening.net
Tel:  1(985)902-8484
MSN: mickalo@bellsouth.net
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


0
mickalo
7/14/2003 4:37:22 PM
perl.beginners 29367 articles. 3 followers. Follow

2 Replies
514 Views

Similar Articles

[PageSpeed] 42

> We have a fairly simple redirect script a url is entered, and even tho
there are
> directions to not enter the "http://www" sometimes we get it or
"http://"...
> what is the simplest method to extract just the domain name if a
> "http://www.somedomain_name.com" or "http://somedomain_name.com" is enter
so we
> can extract just the "somedomain_name.com"

$domain =~ s{^(http:(//)?)?(www.)?}{};

0
manderson
7/15/2003 7:49:11 PM
In article <POENIDJMGJHIICHDIHNPMEHJDMAA.manderson@gcamail.com>, Mark 
Anderson wrote:

>> We have a fairly simple redirect script a url is entered, and even tho
> there are
>> directions to not enter the "http://www" sometimes we get it or
> "http://"...
>> what is the simplest method to extract just the domain name if a
>> "http://www.somedomain_name.com" or "http://somedomain_name.com" is enter
> so we
>> can extract just the "somedomain_name.com"
> 
> $domain =~ s{^(http:(//)?)?(www.)?}{};

And this second substitution seems to work to strip subdirectories 
(www.abc.com/catalog/):

$domain =~ s{(/.*/?)?$}{};

To combine them I'm guessing one would have to capture the "middle":

$domain =~ s{^(http:(//)?)?(www.)?(.*)?(/.*/?)?$}{};
print "$4\n";

(It works on my small example at least)

-K

-- 
Kevin Pfeiffer
International University Bremen
0
pfeiffer
7/16/2003 8:12:29 AM
Reply:

Similar Artilces:

ContextType.Domain gets PrincipalServerDownException unless specify domain controller by name
Hi There Just trying out the new System.DirectoryServices.AccountManagement with Visual Studio 2008 Express Edition.  My scenario:  -Client Windows XP joined to domain -One Windows Server 2003 domain controller / IIS  I want to get the full name of the logged in user. This works if I specify the domain controller name. Specifying the domain name (either fully qualified or NETBIOS) does not work. Any suggestions ? Am I doing something wrong here.   My working code is like this:   Dim domainContext As New System.DirectoryServices.AccountManagement.PrincipalCo...

Get domain name
I am tryng to find the simplest way to get the domain name of the site that some code is running under, on the web I find this: Environment.UserDomainName.ToString Which always returns my server hostname... not what I want..Ask One/Answer One.  maybe something like dis? string url = Request.Url.AbsolutePath; orRequest.Url.DnsSafeHost +Lvl FIVE THOUSAND DRAGON MASTER SOFTWARE ENGINEER my friends call me MOI You can get the hostname from a HttpRequest, e.g.  Page.Request.Url.Host if you are executing in a aspx page.The problem is that since the site may be running with se...

Getting a domain name.
Where would you buy a .com domain name from? On Thu, 15 Sep 2011 14:18:54 +0000, Arthur wrote: > Where would you buy a .com domain name from? There are a whole lot of choices most of which are good. We have settled on Domain Monger. I use www.networksolutions.com, that way you actually own the domain, you have to be careful with some third party domain registration companies as they register the domain on your behalf. but set themselves up as the owner. So if you want to move things or mange the domain you have to deal with them. and trying to get the ownership becomes a h...

Getting Domain Name
How do you capture the domain name from within PB? I assume win api is needed, does anyone know the call? Mike, Since no one has answered you, you might check out FUNCky for PB... the FUNCky.Domain() method returnes the logged in Domain name. Its a little annoying to do through the Win Api so you might save some headaches using an add-on. -Dirk [FUNCky Developer] [dLESKO Inc.] <-- Got FUNCky? Get it now at http://www.funcky.com. FUNCky Rocks! --> Here's another easy way -- using the Microsoft Scripting Host (installed with Win98 and W2K, and also avai...

How to get domain user's first name, last name and e-mail address
Hi everyone, I am able to retrieve the domain/user ID by setting <authentication mode="Windows"/> in the Web.config file, and with the following code in my Default.aspx.,cs page: string strName = Request.ServerVariables["AUTH_USER"]; I would also like to retrieve the users first name, last name and e-mail address from their domain profile, if possible.  Can anyone help me with a code example?  I'm somewhat new to C#/.NET/OOP so if you have it in "C# for Dummies" format, I would be very thankful! Thanks in advance for any help that i...

How to get full domain name ?
I have some function to fetch domain name : /////////// --- start const NERR_Success = 0; function NetWkstaGetInfo(ServerName: LPWSTR; Level: DWORD; BufPtr: Pointer): Longint; stdcall; external 'netapi32.dll' Name 'NetWkstaGetInfo'; function GetNetParam(AParam: Integer): string; var PBuf: LPWKSTA_INFO_100; Res: LongInt; begin Result := ''; Res := NetWkstaGetInfo(nil, 100, @PBuf); if Res = NERR_Success then begin case AParam of 0: Result := string(PBuf^.wki100_computername); 1: Result := string(PBuf^.wki100_lan...

getting only domain names from list
Hello all, I have a list from a logfile that has urls browsed. I have to extract all domainnames considering subdomains as the same as the domainnames eg @list = qw( yahoo.com mail.yahoo.com hotmail.com yahoo.co.in cnn.co.uk news.cnn.co.uk) I would like to write a function that will give me only the unique domainnames @uniq = qw(yahoo.com hotmail.com yahoo.co.in cnn.co.uk) I have a feeling someone would have done this before Thanx Ramprasad A Padmanabhan ...

Need to get domain name
I need to get the user domain as well as the user name. Getting the name is easy but can't find anything that gets me the domain. .Net has Environment.UserDomainName() Does PB have anything similar or does anyone know the API call that will get me what I need? thanks Try this: http://msdn.microsoft.com/library/en-us/netmgmt/netmgmt/netwkstausergetinfo.asp?frame=true <Darren> wrote in message news:42483636.25b8.1681692777@sybase.com... > I need to get the user domain as well as the user name. > Getting the name is easy but can't find anything that gets ...

get parked domain name
--part1_12e.ed205a2.29d39e2c_boundary Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit I just parked a domain name a few days ago and now I want to use it. But I can't seem to access it with the $ENV variables. I've tried $ENV{'SERVER_NAME'} Which I thought would do the trick! Anyone have any tricks up their sleeve? Thanks Tricia --part1_12e.ed205a2.29d39e2c_boundary-- ...

Getting the right most of the domain name
Hello,I want to get the right most name of the a domain name, for example:if the domain is www.myweb.com , I want to get myweb.comsomething.myweb.com -->  myweb.comwww.myweb.com.au -->  myweb.com.ausomething.myweb.com.au -->  myweb.com.auwww.myweb.tv --> myweb.tvwww.something.myweb.net --> myweb.netmy.test.myweb.ca --> myweb.caI want to know if there is a general rule, code or article regarding this issue. I tried the following code, but I am not convinced, because it is not genericpublic static string GetDomainName(string serverName ) {if(!serverName.Contain...

Domain name forwarding
HiI have written a portal content management system, so that different users have different sites such as:www.portalsite.com/default.aspx?SiteID=1www.portalsite.com/default.aspx?SiteID=2       etc. I have managed to URL rewrite, in the global.asax, to give friendly URLs such as:www.portalsite.com/user01www.portalsite.com/user02 However some users have their own registered domain names which they can forward to their portal site.  For example a user may have 'www.mydomainname.com' (hosted with another ISP) which they forward to point to their portal address ...

get the logged in Username and Domain name
Hi Is there any way in a asp.net application to get the logged in clients username and domainname?   Regards, Try with this:        string userName = User.Identity.Name;        string domain = Request.Url.Host; for getting domain name Request.ServerVariables("HTTP_HOST") ======================================Regard,Pradeep SahooTeam LeaderDon't forget to click "Mark as Answer" on the post that helped you. Environment.GetEnvironmentVariable("USERDOMAIN") - To g...

cheapest way to get a domain name?
I have an idea for a domain name, and I want to grab it before someone else gets it. I determined that it is available, but before I spend $14 at one place just to buy it, I figure there has got to be a cheaper place that sells them. I am not planning on actually hosting anything in the next few months at this new domain name, so I am not interested in going through my host (who hosts my current domain, www.middletree.net) So where's the cheapest place to go? Wandering aimlessly around grc.techtalk, I heard middletree mention: > I have an idea for a domain name, and I want ...

Web resources about - Getting the domain name - perl.beginners

Ted Cruz’s Father: Public Education Brainwashes Children Into Communism
Rafael Cruz , father of Ted , went on the Sirius XM show Breitbart News Daily Thursday, where the Cuban-born evangelical preacher outlined his ...

Android Reportedly Generated $31 Billion For Google To Date
Ever wonder how Google makes money from its Android mobile operating system? It makes money through ads and also through the sale of apps in ...

Redford refuses to be drawn into Oscars controversy
US actor Robert Redford refused to be drawn into the Oscars race controversy Thursday as the Sundance Film Festival he founded got underway in ...

Spruce Up a Room In No Time With the Speed Decluttering Game
Decluttering your entire home can take awhile. If you’re pressed for time, but still want to give a room a quick tidying up, the speed decluttering ...

EPA orders Michigan to take 'immediate action' on Flint water crisis
The US Environmental Protection Agency ordered the state of Michigan today to take “immediate action to address serious and ongoing concerns” ...

Facebook to roll out 3D Touch "peek and pop" support within timelines over coming months, starting today ...
Chris Davies / SlashGear : Facebook to roll out 3D Touch “peek and pop” support within timelines over coming months, starting today — Facebook ...

Powerful snowstorm threatens U.S. East Coast; flights canceled
By Ian Simpson WASHINGTON (Reuters) - Washington D.C., New York and other East Coast cities readied fleets of snow plows, thousands of flights ...

A 100 Meter Tall Starkiller Base From The Force Awakens Is Now in Abu Dhabi
That headline pretty much says it all. A company called twofour54 transformed a building in Abu Dhabi to look like Starkiller Base from Star ...

Kremlin Dismisses, Dissidents Applaud British Probe into Litvinenko Murder
Voice of America Kremlin Dismisses, Dissidents Applaud British Probe into Litvinenko Murder Voice of America January 21, 2016 6:31 PM. LONDON—. ...

GM Wants To Tear Down Zipcar With New Car-Sharing Service Maven
Car sharing has been around for a while but most of the big players require you to pay a membership fee, which can be hard to swallow if you’re ...

Resources last updated: 1/22/2016 1:22:25 AM