Answers.Body: <p>Your <code>.htaccess</code> is basically saying "Redirect example.com to www.example.com". </p>
  
  <p>OK, that's cool. so you want to add <code>www</code> to any request that a comes in. I'm guessing you put this <em>after</em> Craft's code? </p>
  
  <p>This actually needs to come <em>before</em> you send the request to Craft.</p>
  
  <p>So, your example should look like this:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  
    #Make sure the rewrite engine is on
    RewriteEngine On
  
    # Redirect non-www requests to www
    RewriteCond %{HTTP_HOST} ^example\.com [NC] 
    RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]
  
    # Send would-be 404 requests to Craft
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
    RewriteRule (.+) index.php?p=$1 [QSA,L]
  
  &lt;/IfModule&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-30T03:06:48.883Z
Answers.LastActivityDate: 2017-10-30T03:06:48.883Z
Answers.UserDisplayName: RitterKnight
Body: <p>I am trying to get pretty urls </p>
  
  <p>In my general.php file I have </p>
  
  <pre><code>'omitScriptNameInUrls' =&gt; true,
  </code></pre>
  
  <p>which works fine and removes the index.php </p>
  
  <p><strong>BUT</strong></p>
  
  <p>When I try to force a <code>www</code> in the htaccess the index.php comes back and I can't seem to remove this.</p>
  
  <p>This is what I have in my htaccess</p>
  
  <pre><code>RewriteEngine on
  RewriteCond %{HTTP_HOST} ^example\.com [NC]
  RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]
  </code></pre>
  
  <p>Any thoughts?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-29T19:19:01.233Z
Comments.Text: Are you certain that you're using Craft 3? Otherwise we should remove the [tag:craft3] tag. (I'm not sure it's relevant anyway.)
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-30T18:03:51.327Z
Comments.Text: yeah I am using the latest craft
Comments.UserDisplayName: rcho
Tags: <craft3><htaccess>
Title: Adding `www` causing it to have index.php
ThreadText: # Adding `www` causing it to have index.php
  
  (Asked by: username_0 on 2017-10-29)
  
  I am trying to get pretty urls
  
  In my general.php file I have
  
  ```
  'omitScriptNameInUrls' => true,
  
  ```
  
  which works fine and removes the index.php
  
  **BUT**
  
  When I try to force a `www` in the htaccess the index.php comes back and I can't seem to remove this.
  
  This is what I have in my htaccess
  
  ```
  RewriteEngine on
  RewriteCond %{HTTP_HOST} ^example\.com [NC]
  RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]
  
  ```
  
  Any thoughts?
  
  **Tags:** craft3, htaccess
  
  > **Comments:**
  > **username_1**: Are you certain that you're using Craft 3? Otherwise we should remove the [tag:craft3] tag. (I'm not sure it's relevant anyway.)  
  > **username_0**: yeah I am using the latest craft  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-10-30. Score: 3
  
  Your `.htaccess` is basically saying "Redirect example.com to www.example.com".
  
  OK, that's cool. so you want to add `www` to any request that a comes in. I'm guessing you put this *after* Craft's code?
  
  This actually needs to come *before* you send the request to Craft.
  
  So, your example should look like this:
  
  ```
  <IfModule mod_rewrite.c>
  
    #Make sure the rewrite engine is on
    RewriteEngine On
  
    # Redirect non-www requests to www
    RewriteCond %{HTTP_HOST} ^example\.com [NC] 
    RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]
  
    # Send would-be 404 requests to Craft
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
    RewriteRule (.+) index.php?p=$1 [QSA,L]
  
  </IfModule>
  
  ```
  
  
  ---
  
  