15 August 2013

PHP Get Current URL

I need to get the current url for some purposes, such as;
  • Check the url if it is used to be. This is required to prevent dublicated content from different urls in your website.
  • Generate social bookmark and like data-href links
It is easy to get the current url in PHP;

<?php 

echo "http://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];

?>


This will give you the exact url of the current page.

No comments: