Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Sep 2011
    Location
    127.0.0.1
    Posts
    62
    Thanks
    18
    Thanked 0 Times in 0 Posts

    How to get if user goes to www. or without www.?

    Hi. My english is not excelent.... I need to get the url of website, where visitor actually is, then I need to get, if there is www. before my domain. How to do that? Thx for any help.
    My website is here: http://www.moowdesign.eu/. It is not complete yet, and I want to add language translations for some languages(including english).

  • #2
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts
    try this:

    PHP Code:
    <?php
    $url
    ="".$_SERVER['HTTP_HOST']."".$_SERVER['REQUEST_URI']."";
    echo 
    $url;
    ?>


    Dan
    http://360-tactics.co.uk/forum/index.php

    Crime-Wave

    please post your code wrapped in tags
    please post your PHP wrapped in tags

  • #3
    New Coder
    Join Date
    Sep 2011
    Location
    127.0.0.1
    Posts
    62
    Thanks
    18
    Thanked 0 Times in 0 Posts
    thx a lot. this is script, that is actually working for me:

    PHP Code:
    <?php
    function is_www() {
    $url=$_SERVER['HTTP_HOST'];
    if (
    strstr($url,"www.")) {return 1;} else {return 0;}
    }

    echo 
    is_www();
    ?>
    My website is here: http://www.moowdesign.eu/. It is not complete yet, and I want to add language translations for some languages(including english).


  •  

    Posting Permissions

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