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
    Nov 2006
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    removing all www.

    my member script kinda messes up whenever there is www in front of my url.

    so is there anyway to edit the htaccess so ALL urls beginning with a WWW will automatically change to one without the WWW?

  • #2
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    865
    Thanks
    7
    Thanked 29 Times in 28 Posts
    I haven't tested this code...as I have never needed to use it...but try it out and let's know if there are any errors.

    RewriteCond %{HTTP_HOST} !^your_site_domain_here\.com$ [NC]
    RewriteRule .* http://your_site_domain_here.com/ [L,R=301]

    Note: you need to set ReWriteEngine on

    good luck

  • #3
    New Coder
    Join Date
    Nov 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jl9148 View Post
    my member script kinda messes up whenever there is www in front of my url.

    so is there anyway to edit the htaccess so ALL urls beginning with a WWW will automatically change to one without the WWW?

    I'm not sure how you would edit the .htaccess but this could be accomplished with PHP also.

    PHP Code:
    <?php
    if (substr($_SERVER['SERVER_NAME'],0,3) == 'www') { // if www. is subdomain
        
    $url substr($_SERVER['SERVER_NAME'],4,strlen($_SERVER['SERVER_NAME'])); // remove the www.
        
    $url .= $_SERVER['PHP_SELF']; // Add directory and file name to url
        
    header('Location: http://'.$url); // redirect the browser to url without www
    }
    ?>
    Placing that on the very top of the web page will force no www subdomain. Hope this helps.

    ~UberDragon


  •  

    Posting Permissions

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