View Full Version : manipulating segments of current url

11-16-2011, 12:51 PM
Hi Guys,
Hope you can help. How do you simply output the current url in the browser i.e if i am in google.com I want google.com outputted and so on.

Also on multilanguage sites if my url is say www.mydomain.com/en/about.html or http://www.mydomain.com/en/animals/h...stallions.html I want to be able to manipulate the url so I can change en to fr for example when I jump between english and french pages. I want users to be able to switch the language of that particular page by clicking a link. I need to be able to switch segment one of the url (en,fr,de etc...)dynamically somehow instead of hardcoding a link into each page.

Any ideas?


11-16-2011, 02:53 PM
To output the current URL in the browser

//HTTP_HOST is the base url(basically the url that made the request
//PHP_SELF is the path of the file of the page you're at relative to the doc root.
//Combined, this gives you the absolute path to a file


//Browser redirect (which is what I'm assuming you're looking for)

header('Location: '. 'Path to your file here');

As for dynamically loading links, I would use a database for that.