[resolved] How to get rid of www for blog subdirectory (2 posts)

  1. ElleG
    Posted 4 years ago #

    I cannot seem to get rid of the www. at the beginning of my blog url. I got rid of it for my main page (www.ellevateme.com will automatically redirect to ellevateme.com), but it will not work for my blog subdirectory (www.ellevateme.com/blog).

    This is what the .htaccess file contains in my root directory (public_html):
    # Use PHP5 Single php.ini as default
    AddHandler application/x-httpd-php5s .php

    # redirect all traffic to the www-less domain
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www.ellevateme.com$ [NC]
    RewriteRule ^(.*)$ http://ellevateme.com/$1 [R=301,L]

    I see there is also a .htaccess file in the /blog subdirectory, and it contains what WP put in:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /blog/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]

    # END WordPress

    I tried adding this:

    #redirect to www-less url
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www.ellevateme.com/blog/$[NC]
    RewriteRule ^(.*)$ http://ellevateme.com/blog/$1 [R=301,L]

    to that .htaccess file, but it didn't seem to do anything. If I go to http://www.ellevateme.com/blog the url stays just like that, and if I go to ellevateme.com/blog, it adds in the www. Does anyone know how to fix this?

  2. ElleG
    Posted 4 years ago #

    I figured it out. Someone at my host clued me in.

    I didn't need to make any changes to the .htaccess file in the /blog subdirectory. All I had to do was go to my WordPress dashboard, go to Settings, and change my site and blog url to the www-less version (ellevateme.com/blog).

    Et voila! No more www in front of my url for my blog.

Topic Closed

This topic has been closed to new replies.

About this Topic