How Can I Get the Current Page URL of a Web Page

Full URL of Current Page

To get the full URL of the current page,
which takes the form http://www.website.com/Directory/pagename.html,
you can use the following code below:

The $_SERVER['HTTP_HOST'] gets the www.website.com name of the website in use.

The $_SERVER['REQUEST_URI'] returns the directory pathway and file name of the page you are on.

Directory Pathway and File name

To return just the directory pathway and the file name of the web page, you can use the following code:

So this code above returns the part after the type of domain name the web page is.

Just the Directory Pathway

To return just the directory pathway of the current web page URL, you can use the following code:

This code above returns just the directory pathway to the current page URL.

Just the File Name

To just return the file name of the current page,, you can use the following code:

This code above returns just the directory pathway to the current page URL.

Just the File Name Without the File Extension

Sometimes you may just want to return the file name without the file extension.
To do this, you can use the following code:

The code above returns just the file name without the file extension included.