Results 1 to 7 of 7

Thread: Remove "www" PHP

  1. #1
    Szise is offline Net Builder
    Join Date
    Dec 2008
    Posts
    426
    Thanks
    14
    Thanked 33 Times in 29 Posts

    Remove "www" PHP

    I have this code :

    <?php
    $string = $_SERVER['HTTP_HOST'];
    echo ucfirst($string); // Capitalize 1st
    ?>
    Can someone tell me what to add to this code to remove "www" behind.

    If i access my domain.com will show Domain.com but if i access www.domain.com will show Www.domain.com.

    How to modify the code to remove www. when i access my domain using www.domain.com .
    ...

  2. #2
    Mr.Bill's Avatar
    Mr.Bill is offline One is glad to be of service
    Join Date
    Dec 2008
    Location
    Redmond, Oregon
    Posts
    828
    Blog Entries
    1
    Thanks
    72
    Thanked 350 Times in 182 Posts
    Could just remove that and in your htaccess add something like this

    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www.example.com
    RewriteRule ^.*$ http://example.com%{REQUEST_URI} [R=301,L]

    Reverse IP Check ಠ_ಠ Proxy Sites
    <?php if ($youask == 'stupid question') { echo ('stupid answer'); } ?>

  3. #3
    Szise is offline Net Builder
    Join Date
    Dec 2008
    Posts
    426
    Thanks
    14
    Thanked 33 Times in 29 Posts
    No, it's for my Privacy Policy, must be in Php.

    The code will show the domain name in the Privacy Policy and will capitalize the first character.

    Everything is fine untill here but if i access my Privacy Policy from my domain with www. the domain will appear as Www.domain.com instead of Domain.com so i need this code a little modified to exclude the www. when the domain is accesed with www. behind.
    ...

  4. #4
    Shenron's Avatar
    Shenron is offline Administrator
    Join Date
    Dec 2008
    Location
    Portugal
    Posts
    1,900
    Blog Entries
    2
    Thanks
    561
    Thanked 548 Times in 368 Posts
    Can't you do it like this:

    (I'm a terrible coder, so this is just an idea)

    Capitalize the first 4 chars:

    WWW.Domain.com

    Then:

    Lower the first 3

    www.Domain.com


  5. #5
    Ogle is offline Newbie Net Builder
    Join Date
    Mar 2009
    Posts
    65
    Thanks
    8
    Thanked 7 Times in 4 Posts
    Code:
    <?php
    $string = str_replace('www','',$_SERVER['HTTP_HOST']);
    echo ucfirst($string); // Capitalize 1st
    ?>

  6. #6
    Mr.Bill's Avatar
    Mr.Bill is offline One is glad to be of service
    Join Date
    Dec 2008
    Location
    Redmond, Oregon
    Posts
    828
    Blog Entries
    1
    Thanks
    72
    Thanked 350 Times in 182 Posts
    That is of great help. Thank you for helping out. Only need to change to 'www' to 'www.' So it would work correctly.

    Thank you, Now all my sites will be uniform

    Reverse IP Check ಠ_ಠ Proxy Sites
    <?php if ($youask == 'stupid question') { echo ('stupid answer'); } ?>

  7. #7
    Szise is offline Net Builder
    Join Date
    Dec 2008
    Posts
    426
    Thanks
    14
    Thanked 33 Times in 29 Posts
    Yes, Thank You, finally working how i want.
    ...

Similar Threads

  1. What's "new" about "Content Curators"?
    By memenode in forum Content and Writing
    Replies: 2
    Last Post: 12 July, 2012, 17:28 PM
  2. Replies: 1
    Last Post: 29 January, 2010, 04:16 AM
  3. "Dofollow" & "Nofollow" Blogs ?
    By Padalda in forum Blogging
    Replies: 10
    Last Post: 4 October, 2009, 07:19 AM
  4. Replies: 0
    Last Post: 14 August, 2009, 09:01 AM
  5. How to remove "Genuine Windows Validation"?
    By sachin410 in forum Tech-Talk
    Replies: 2
    Last Post: 29 July, 2009, 16:37 PM

Tags for this Thread

Bookmarks

Posting Permissions

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