Sometimes the location: is not given as part of the HTML response header.
Does anyone know how to determine the filename without this key piece of information?
Example http://www.somewebsite.com
If you find a location: in the HTML response header you know the filename. Location: index.html
Any ideas?
Get file name from URL
Moderator: General Moderators
-
Peter Kelly
- Forum Contributor
- Posts: 143
- Joined: Fri Jan 14, 2011 5:33 pm
- Location: England
- Contact:
Re: Get file name from URL
Might help if you look into the function parse_url http://uk.php.net/manual/en/function.parse-url.php
Re: Get file name from URL
I already checked out that function. It breaks up the url into path and filename but the filename has to be part of the url.
Re: Get file name from URL
if your site open with index.php then you should use conical tag for the redirection.
-
Peter Kelly
- Forum Contributor
- Posts: 143
- Joined: Fri Jan 14, 2011 5:33 pm
- Location: England
- Contact:
Re: Get file name from URL
Yeah but if it breaks it up then you can piece it back together
Surely that would work for what you need?
Code: Select all
$url = parse_url(http://username:password@hostname/path?arg=value#anchor'));
echo $url['scheme'] . ":" . $url['host'] .$url[path'];