Have a look at $_SERVER['REQUEST_URI']
, i.e.
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
(Note that the double quoted string syntax is perfectly correct)
If you want to support both HTTP and HTTPS, you can use
$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
Editor’s note: using this code has security implications. The client can set HTTP_HOST and REQUEST_URI to any arbitrary value it wants.
Related Posts:
- Get the full URL in PHP
- Get the full URL in PHP
- what does a .php?id=&value=value means?
- Remove all special characters from a string
- Check if URL has certain string with PHP
- How get value from URL
- Google Calendar API event update always return 404 “not found” error
- Difference between “as $key => $value” and “as $value” in PHP foreach
- How do I get a YouTube video thumbnail from the YouTube API?
- Array to String PHP?
- currently unable to handle this request HTTP ERROR 500
- How to fix “Headers already sent” error in PHP
- PDOException: SQLSTATE[HY000] [2002] No such file or directory
- How do I get a file extension in PHP?
- Getting an error when I visit http://localhost
- XAMPP Port 80 in use by “Unable to open process” with PID 4
- Regex to check for new line
- Elegant way to search for UTF-8 files with BOM?
- Can you “compile” PHP code and upload a binary-ish file, which will just be run by the byte code interpreter?
- Is SAJAX dead? What to replace with?
- Invalid argument supplied for foreach()
- Remove the last character from a string
- How to prevent Browser cache for php site
- break out of if and foreach
- Redirect vs RedirectMatch
- Can curl make a connection to any TCP ports, not just HTTP/HTTPS?
- Error 330 (net::ERR_CONTENT_DECODING_FAILED):
- What does __FILE__ mean?
- Fatal error: Call to a member function bind_param() on boolean [duplicate]
- Weird PHP error: ‘Can’t use function return value in write context’
- How do I fix “Undefined variable” error in PHP?
- How do I get a YouTube video thumbnail from the YouTube API?
- How do you parse and process HTML/XML in PHP?
- Is there a difference between the UTC and Etc/UTC time zones?
- Fatal error: Call to a member function prepare() on null
- PHP mail not working for some reason
- move_uploaded_file gives “failed to open stream: Permission denied” error
- PHP convert XML to JSON
- PHP if not statements
- PHP with MySQL 8.0+ error: The server requested authentication method unknown to the client
- WordPress Error : Upload folder is not writable. Export and file upload features will not be functional
- How to call function of one php file from another php file and pass parameters to it?
- SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
- Is it possible to run .php files on my local computer?
- how to get id from URL using php
- Fatal error: Cannot use object of type mysqli_result
- mysql_field_name to the new mysqli
- mysqli_select_db() expects parameter 1 to be mysqli, string given
- how to convert object into string in php
- PHP Fatal error: Call to undefined function mssql_connect()
- Call to a member function on null?
- how to ping ip addresses in php and give results
- do_shortcode not working
- Only variable references should be returned by reference – Codeigniter
- PHP Unset Session Variable
- “Fatal error: Cannot redeclare function”
- What does MYSQLI_NUM mean and do?
- Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (CodeIgniter + XML-RPC)
- php get all url variables
- How to remove unused dependencies from composer?
- Laravel 5 Clear Views Cache
- how to get date of yesterday using php?
- How can I fetch all items from a DynamoDB table without specifying the primary key?
- How to extract and access data from JSON with PHP?
- How to convert array to SimpleXML
- WordPress query single post by slug
- TCPDF ERROR: Some data has already been output, can’t send PDF file
- Deprecated: mysql_query() [duplicate]
- Limit String Length
- Call to undefined function mysql_query() with Login [duplicate]
- Is there a function to make a copy of a PHP array to another?
- How to POST JSON Data With PHP cURL?
- htmlentities() vs. htmlspecialchars()
- How to run PHP locally on MacOS
- Fastest way to implode an associative array with keys
- PhpMailer SMTP NOTICE: EOF caught while checking if connected
- Call PHP function from jQuery?
- PhpMailer SMTP NOTICE: EOF caught while checking if connected
- What is the meaning of sprintf(): Too few arguments
- Paypal IPN Verification Postback with HTTPS
- Using PHP 7 with WAMP
- Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
- PHP: date function to get month of the current date
- Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given… what I do wrong?
- How to make PDF file downloadable in HTML link?
- PHP: bootstrap.php
- Display array values in PHP
- Php create a file if not exists
- What is a templating language?
- Page redirect after certain time PHP
- Logout button php
- Determining Referer in PHP
- Unset cookies php
- PHP Like thing similar to MySQL Like, for if statement?
- Redirecting from HTTP to HTTPS with PHP
- Check if $_POST exists
- PHP syntax question: What does the question mark and colon mean? [duplicate]
- PHP & Case Sensitivity
- PHP Header redirect not working [duplicate]
- PHP – Fatal error: Unsupported operand types