Title: .htaccess modification
Last modified: August 18, 2016

---

# .htaccess modification

 *  [rollotamasi](https://wordpress.org/support/users/rollotamasi/)
 * (@rollotamasi)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/htaccess-modification/)
 * Hi guys, i wish to add to the current .htaccess file that resides in my blog 
   root so that if a user types in [http://domain.com](http://domain.com) they’re
   automatically redirected to [http://www.domain.com](http://www.domain.com).
 * I have opened up the current .htaccess file and I found the following:
    # BEGIN
   WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /blog/ RewriteCond%{
   REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /blog/
   index.php [L] </IfModule>
 * # END WordPress
 * To enforce the www i added the following to the .htaccess file:
    Options +FollowSymLinks
   RewriteEngine On RewriteCond %{HTTP_Host} ^cormacmoylan.com/blog [NC] RewriteRule
   ^(.*)$ [http://www.cormacmoylan.com/blog/$1](http://www.cormacmoylan.com/blog/$1)[
   L,R=301]
 * But it doesn’t enforce the rule. Does anyone know where i’m going wrong?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Jeff Cole](https://wordpress.org/support/users/upekshapriya/)
 * (@upekshapriya)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/htaccess-modification/#post-468224)
 * To make your life much easier, although maybe less satisfying, there’s a plugin
   that will do this for you at
 * [http://txfx.net/code/wordpress/enforce-www-preference/](http://txfx.net/code/wordpress/enforce-www-preference/)
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [19 years, 8 months ago](https://wordpress.org/support/topic/htaccess-modification/#post-468229)
 * The .htaccess way is better, IMO.
 * Few things:
    -“HTTP_Host” should be all caps. HTTP_HOST is the correct way. This
   is probably why it’s not working, caps matters. -The convention for RewriteRules
   is to have the L last. So use “[R=301,L]” instead. Not sure if this matters or
   not, but still. – Your rules should be BEFORE the #BEGIN WordPress line if you
   want them to work.
 * I use the same sort of thing, actually. Only I enforce no www in my URL. See 
   [http://no-www.org](http://no-www.org) . 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘.htaccess modification’ is closed to new replies.

## Tags

 * [htaccess](https://wordpress.org/support/topic-tag/htaccess/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * Last activity: [19 years, 8 months ago](https://wordpress.org/support/topic/htaccess-modification/#post-468229)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
