Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder howie2009's Avatar
    Join Date
    May 2009
    Thanked 0 Times in 0 Posts

    manipulating segments of current url

    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?


  • #2
    New Coder
    Join Date
    Sep 2010
    The Twilight Zone
    Thanked 2 Times in 2 Posts
    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
    echo $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
    //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.


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts