More accurate way (including host port) would be to use this
function path2url($file, $Protocol="http://") {
return $Protocol.$_SERVER['HTTP_HOST'].str_replace($_SERVER['DOCUMENT_ROOT'], '', $file);
}
More Related Contents:
- URL Redirect / URL Masking [closed]
- URL rewriting with PHP
- Get the full URL in PHP
- PHP validation/regex for URL
- open_basedir restriction in effect. File(/) is not within the allowed path(s):
- Passing base64 encoded strings in URL
- Replace URLs in text with HTML links
- Passing arrays as url parameter
- How do I use filesystem functions in PHP, using UTF-8 strings?
- How to get directory size in PHP
- Get Last Part of URL PHP
- Passing multiple variables to another page in url
- Best way to get files from a dir filtered by certain extension in php [duplicate]
- How to get the previous url using PHP
- How to delete a folder with contents using PHP [duplicate]
- Apache rewrite – get original URL in PHP
- Get current domain
- Loop code for each file in a directory [duplicate]
- PHP Application URL Routing
- http_build_query with same name parameters
- What is the “?” symbol in URL used for in php?
- Check if URL has certain string with PHP
- PHP – Add link to a URL in a string
- What does the dot-slash do to PHP include calls?
- PHP: How to resolve a relative url
- PHP & Hash / Fragment Portion of URL
- getting the full url including the query string after hash
- How to properly create HTML links in PHP?
- How do I apply URL normalization rules in PHP?
- Detecting a url using preg_match? without http:// in the string