How to get the current page URL in PHP, WordPress, Codigniter, Joomla and Java Script

How to get the current page URL in PHP, WordPress, Codigniter, Joomla and Java Script? Many times you want to know the current page URL. Here i am going to tell you how to get the current page URL in PHP, WordPress, Codigniter, Joomla and Java Script.

PHP

$current_page_URL = $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];

Here $_SERVER[“SERVER_NAME”] will give you the doman name of your site and $_SERVER[“REQUEST_URI”] will give you the rest

example:- for the URL https://www.themevina.com/how-to-get-current-page-url-in-php-wordpress-codigniter-joomla-java-script/

$_SERVER[“SERVER_NAME”] will give you themevina.com

$_SERVER[“REQUEST_URI”] will give you /how-to-get-current-page-url-in-php-wordpress-codigniter-joomla-java-script/

If you want to include Http or Https then add this condition

$current_page_URL =(isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"]==”on”) ? “https://” : “http://”;
$current_page_URL = $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];

WordPress

the_permalink()

This function returns you the link of the current page or post. If this function is used inside a WordPress loop than it will return the link of the current post inside the loop.

Alternatively you can use the $_SERVER[“SERVER_NAME”] . $_SERVER[“REQUEST_URI”] also.

get_bloginfo(“siteurl“) it will return you the blog url set in the wordpress->Settings->General

Joomla

You can use the Joomla API to find the current URL of the page.

JURI::current()

This will return current page URL.

JURI::base() this will return you the base URL of your Joomla Site.

Codeigniter

base_url()

Returns your site base URL, as specified in your config file

current_url()

Returns the full URL (including segments) of the page being currently viewed.

base_url()

Returns your site base URL, as specified in your config file.

Java Script

window.location

It will return you current page url in Java Script.

Share this :

Comments are closed.

Related post

Free Responsive Website templates

ThemeVina is Best site for free sharing and download Wordpress themes, Joomla templates, Responsive website templates and more HTML templates.

All template in Site are free. You can download and install for your site.

Contact us

  • Brand: Theme Vina
  • Email: admin@themevina.com
  • Website: www.themevina.com
  • Address: 367 Tran Hung Dao Street
  • Location: Thai Binh City, Thai Binh, Viet Nam

Newsletter