• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

IntelyBlog

A blog site that is intelligent

  • Hosting
  • jQuery
  • Programming

https

How to get current page full URL in PHP

September 7, 2021

Post Views: 11

Step 1: Deciding on the SSL protocol whether the site using http or https.

if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
   $url = 'https';
} else {
   $url = 'http';
}

Step 2: Append domain name or IP to the URL

$url .= $_SERVER['HTTP_HOST'];

Step 3: Append the current page URL after domain / IP

$url .= $_SERVER[‘REQUEST_URI’]

Step 4: Let’s put all these together and create a function that can be reused.

function getfullpageurl() {
    if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')   
         $url = "https://";   
    else  
         $url = "http://";   
       
    $url.= $_SERVER['HTTP_HOST'];   
    
    $url.= $_SERVER['REQUEST_URI'];    
      
    return $url;  
}

Filed Under: PHP Tagged With: domain name, host, https, page url, PHP, server, ssl

Enforcing https on all WordPress pages

August 30, 2021

Post Views: 13

Step 1

Go to your file manager or access your files via any FTP client.

Step 2

Open your .htaccess file in edit mode (Where you can update the file and save.)

Step 3

Include the following two lines below RewriteEngine On as shown.

RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Step 4

Finally save your updates and close.

And that’s it! your pages will be loading with https.

Filed Under: Hosting Tagged With: cpanel, hosting, htaccess, https, ssl, WordPress

Primary Sidebar

Recent Posts

  • How to convert any full URL path to relative to WordPress installation (root)
  • How to write if else statement in a single line (compact if else statement) using PHP
  • How to programmatically add a WordPress admin user using functions.php
  • How to check if a file exists on a remote server using CURL
  • How to create WhatsApp share button in HTML

Recent Comments

No comments to show.

Archives

  • April 2022
  • February 2022
  • September 2021
  • August 2021

Categories

  • Hosting
  • jQuery
  • PHP
  • WhatsApp
  • WordPress

Content

Our team will teach you the art of writing audience-focused content that will help you achieve the success you truly deserve.

Learn more about content.

Copyright © 2021 IntelyBlog

  • html
  • jquery
  • https
  • css
  • slice
  • WhatsApp