Results 1 to 7 of 7

Thread: Remove "www" PHP

  1. #1

    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
    Join Date
    Dec 2008
    Location
    Redmond, Oregon
    Posts
    828
    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
    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
    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
    Code:
    <?php
    $string = str_replace('www','',$_SERVER['HTTP_HOST']);
    echo ucfirst($string); // Capitalize 1st
    ?>

  6. #6
    Join Date
    Dec 2008
    Location
    Redmond, Oregon
    Posts
    828
    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
    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, 05: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
  •