adding WWW in front of my domain

10 replies
  • WEB DESIGN
  • |
When I type my domain in my browser (including the www) after I hit enter it reverts back to http:// domainname.com
From what I understand the only way to fix this is to goto the htaccess file and add this:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^yoursite\.com
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R=permanent,L]

*This should automatically add the www in the domain, even if you leave it out when typing it in your browser.

-The problem is I went to my htaccess file and there is no text or anything in this file. I pasted the above text anyway and saved it and it didnt work. This is on wordpress with hostgator hosting.

How do I get the www back in my site name?
#adding #domain #front #www
  • Profile picture of the author RemingtonSteele
    If you're using Wordpress, it's odd that there's nothing in the .htaccess file. Maybe the file isn't currently writable?

    In any event, I would just try creating a new one using Notepad (be sure to select "All Files" under "Save as type" so that it doesn't save it as a .txt file) and put the following code in it:

    Code:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    
    Options -Indexes
    # Sets the default file for directories
    DirectoryIndex index.php index.html index.htm default.htm index.php3 index.phtml index.php5 index.shtml mwindex.phtml
    
    RewriteEngine on
    # Redirects http://yoursite.com to http://www.yoursite.com
    RewriteCond %{HTTP_HOST} ^yoursite.com$ [NC]
    RewriteRule ^(.*)$ http://www.yoursite.com/$1 [L,R=301]
    The last four lines are what you need for the redirect, and the other code is for Wordpress and default files for directories (i.e., when a request is made for a directory, the server will look for index.php first, then index.html, index.htm, etc.) until it finds an index file to serve.

    Just delete or overwrite the current .htaccess file with the new one, and hopefully that will fix your problem.
    {{ DiscussionBoard.errors[4048419].message }}
  • Profile picture of the author dbdnvikas
    I would like to get the answer because my wp blog Niche Bloggers is getting the same problem..
    {{ DiscussionBoard.errors[4048901].message }}
  • Profile picture of the author elejpee
    Banned
    [DELETED]
    {{ DiscussionBoard.errors[4048940].message }}
    • Profile picture of the author michaely
      Hi Guys

      If you're using wordpress, just do the following:

      1) Goto your wordpress admin page
      2) Under "Settings" click "General"
      3) Add www to 2 fields:
      Wordpress Address (URL)
      Site Address (URL)
      4) click "Save changes
      {{ DiscussionBoard.errors[4048978].message }}
      • Profile picture of the author Mike Baker
        Originally Posted by michaely View Post

        Hi Guys

        If you're using wordpress, just do the following:

        1) Goto your wordpress admin page
        2) Under "Settings" click "General"
        3) Add www to 2 fields:
        Wordpress Address (URL)
        Site Address (URL)
        4) click "Save changes
        This is your answer guys!
        Signature

        {{ DiscussionBoard.errors[4051135].message }}
        • Profile picture of the author carp104
          The theme I am using does not have a permalinks or settings option on the left menu...very odd.

          Anyway, I seemed to have fixed the problem through phpmyadmin in the cpanel with the following steps:

          1. Backup your database and save the copy off-site.
          2. Login to phpMyAdmin.
          3. Click the link to your Databases.
          4. A list of your databases will appear. Choose the one that is your WordPress database.
          5. All the tables in your database will appear on the screen.
          6. From the list, look for wp_options. Note: The table prefix of wp_ may be different if you changed it when installing.
          7. Click on the small icon indicated as Browse.
          8. A screen will open with a list of the fields within the wp_options table.
          9. Under the field option_name, scroll down and look for siteurl.
          10. Click the Edit Field icon which usually is found at the far left at the beginning of the row.
          11. The Edit Field window will appear.
          12. In the input box for option_value, carefully change the URL information to the new address.
          13. Verify this is correct and click Go to save the information.
          14. You should be returned to your wp_options table.
          15. Look for the home field in the table and click Edit Field. Note There are several pages of tables inside wp_options. Look for the > symbol to page through them.
          16. In the input box for option_value, carefully change the URL information to the new address.
          17. Verify this is correct and click Go to save the information.
          {{ DiscussionBoard.errors[4053337].message }}
      • Profile picture of the author manoballs
        This is awesome thanks!

        Originally Posted by michaely View Post

        Hi Guys

        If you're using wordpress, just do the following:

        1) Goto your wordpress admin page
        2) Under "Settings" click "General"
        3) Add www to 2 fields:
        Wordpress Address (URL)
        Site Address (URL)
        4) click "Save changes
        {{ DiscussionBoard.errors[6019384].message }}
  • Profile picture of the author aspnaren
    A quick fix to this is to redirect http://yoursite.com to http://www.yoursite.com
    from your domain control panel
    {{ DiscussionBoard.errors[4050381].message }}
  • Profile picture of the author DarkSlayer
    Originally Posted by carp104 View Post

    When I type my domain in my browser (including the www) after I hit enter it reverts back to http:// domainname.com
    From what I understand the only way to fix this is to goto the htaccess file and add this:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^yoursite.com
    RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R=permanent,L]

    *This should automatically add the www in the domain, even if you leave it out when typing it in your browser.

    -The problem is I went to my htaccess file and there is no text or anything in this file. I pasted the above text anyway and saved it and it didnt work. This is on wordpress with hostgator hosting.

    How do I get the www back in my site name?
    Use it instead (remove ^ and $):
    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^yoursite.com
    RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]
    {{ DiscussionBoard.errors[4050426].message }}
    • Profile picture of the author st8ic
      Originally Posted by DarkSlayer View Post

      Use it instead (remove ^ and $):
      should work...
      {{ DiscussionBoard.errors[4056142].message }}
  • Profile picture of the author opencreativs
    yup.. should work
    Signature

    Animated Corporate/Explainer video production for $300 / minute
    http://www.opencreativs.com

    {{ DiscussionBoard.errors[4060196].message }}

Trending Topics