Geekpedia Programming Tutorials









URL Reconstruction Using PHP

Reconstruct an URL in PHP by concatenating the domain-name, path and query string from three different variables.

On Wednesday, April 23rd 2008 at 10:46 PM
By Andrei Pociu (View Profile)
-----   (Rated 0 with 0 votes)
Contextual Ads
More PHP Resources
Advertisement
  1. // Domain-name
  2. $Domain = $_SERVER['HTTP_HOST'];
  3. // File Path
  4. $Path = $_SERVER['SCRIPT_NAME'];
  5. // Query String
  6. $QString = $_SERVER['QUERY_STRING'];
  7.  
  8. // Put together the three strings
  9. $URL = "http://".$Domain.$Path."?".$QString; // Or use $_SERVER['REQUEST_URI'] to get the path and query string together
Digg Digg It!     Del.icio.us Del.icio.us     Reddit Reddit     StumbleUpon StumbleIt     Newsvine Newsvine     Furl Furl     BlinkList BlinkList

Rate Rate this code snippet
Comment Current Comments
There are no comments.

Comment Comment on this tutorial
Name: Email:
Message:
Comment Related Source Code
There is no related code.

Comment Related Tutorials
There are no related tutorials.

Jobs PHP Job Search
My skills include:
Enter a City:

Select a State:


Advanced Search >>
Latest Tech Bargains

Advertisement

Free Magazine Subscriptions

Today's Pictures

Today's Video

Other Resources

Latest Downloads

Latest Icons