Reputation: 11
What would be the best way to split URL http://www.mysite.com/?name
How to split the /?name from the above url and be able to put in a id from the server. The ids are already on the server I just need to change this so that someone with that id could put in:
http://www.mysite.com/username.
Upvotes: 1
Views: 819
Reputation: 3149
use parse_url output is
scheme - e.g. http
host
port
user
pass
path
query - after the question mark ?
fragment - after the hashmark #
like
$url = 'http://username:password@hostname/path?arg=value#anchor';
print_r(parse_url($url));
output
Array
(
[scheme] => http
[host] => hostname
[user] => username
[pass] => password
[path] => /path
[query] => arg=value
[fragment] => anchor
)
Upvotes: 2
Reputation: 33501
First, you should use URL rewriting to convert all the virtual addresses into script calls. Like www.mysite.com/username
is actually served as www.mysite.com/?name=username
. Inside the script, you would simply access the name
variable from GET parameters.
There are thousands of tutorials available on the net, this one seems good enough : http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/
Upvotes: 2