hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : simple php code please
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

simple php code please

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 12-05-2004, 03:00 PM
saghir69 saghir69 is offline
Web Hosting Master
 
Join Date: Jun 2004
Posts: 889

simple php code please


http://www.webhostingtalk.com/showthread.php

can someone do a code for me that will strip a url like this

http://www.webhostingtalk.com/showthread.php?whatever into webhostingtalk.com

and

www.subdomain.maindomain.com into maindomain.com

but there might be problems with ,info or . co.uk domains etc

or subdomains

any one know a code to get just the domain and the right extention for a given string

example sub.domain.info

should return domain.info

can someone help?

Reply With Quote


Sponsored Links
  #2  
Old 12-05-2004, 04:17 PM
Akyriel Akyriel is offline
Junior Guru Wannabe
 
Join Date: Oct 2004
Location: Orlando
Posts: 56
Use the PHP parse_url() function.

This function returns an associative array containing any of the various components of the URL that are present. If one of them is missing, no entry will be created for it. The components are :

scheme - e.g. http
host
port
user
pass
path
query - after the question mark ?
fragment - after the hashmark #

$url = parse_url("http://username:password@hostname/path?arg=value#anchor");

will return

$url['scheme'] = http
$url['host'] = hostname
$url['user'] = username
$url['pass'] = password
$url['path'] = /path
$url['query'] = arg=value
$url['fragment'] = anchor

Reply With Quote
  #3  
Old 12-06-2004, 02:13 AM
Burhan Burhan is offline
Community Guide
 
Join Date: Jul 2003
Location: Kuwait
Posts: 5,100
If you are using Apache with mod_rewrite support, then you don't need PHP to do this. You can just setup redirects (or, even use .htaccess).

__________________
In order to understand recursion, one must first understand recursion.
If you feel like it, you can read my blog
Signal > Noise

Reply With Quote
Sponsored Links
  #4  
Old 12-06-2004, 06:57 AM
saghir69 saghir69 is offline
Web Hosting Master
 
Join Date: Jun 2004
Posts: 889
Thanks guys

Its working now, I used PHP parse_url()

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Cloud Industry Forum Establishes Cloud Service Provider Code of Practice Web Hosting News 2012-09-21 12:38:23
DigiCert Launches Extended Validation Code Signing Certificates Web Hosting News 2012-08-15 15:30:28
Non-Profit New Zealand Computer Society to Develop Cloud Code of Practice Web Hosting News 2011-09-02 17:22:36
SSL Certificate Authority Comodo Providing Intel Application Certification Web Hosting News 2011-08-12 15:51:28
Web Host DreamHost Contributing Code for Ceph File System to OpenStack Web Hosting News 2011-06-23 20:40:32


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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 Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?