Answers.Body: <p><em>Maybe there's a better solution but:</em></p>
  <p><code>{{ craft.app.request.absoluteUrl()|replace({'https://': &quot;https://www.&quot;}) }}</code></p>
  <p><a href="https://twig.symfony.com/doc/3.x/filters/replace.html" rel="nofollow noreferrer">https://twig.symfony.com/doc/3.x/filters/replace.html</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-21T23:42:22.987Z
Answers.Text: That works nicely, thank you!
Answers.UserDisplayName: Jake1293
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-21T21:37:47.807Z
Answers.LastActivityDate: 2021-06-21T21:37:47.807Z
Answers.UserDisplayName: user15280052
Body: <p>How can I add &quot;www&quot; to the output of {{ craft.app.request.absoluteUrl }}?</p>
  <p>In my .env file I have</p>
  <pre><code>DEFAULT_SITE_URL=&quot;https://www.mysite.com&quot;
  </code></pre>
  <p>but</p>
  <pre><code>{{ craft.app.request.absoluteUrl() }}
  </code></pre>
  <p>only outputs <a href="https://mysite.com" rel="nofollow noreferrer">https://mysite.com</a> without the &quot;www&quot;.  How can I fix that?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-22T14:38:53.333Z
Comments.Text: Craft will listen on whatever vhost you give it. Is your web server setup to redirect non-www to www?
Comments.UserDisplayName: RitterKnight
Tags: <url><siteurl><env>
Title: Siteurl - craft.app.request.absoluteUrl() output missing "www"
ThreadText: # Siteurl - craft.app.request.absoluteUrl() output missing "www"
  
  (Asked by: username_0 on 2021-06-21)
  
  How can I add "www" to the output of {{ craft.app.request.absoluteUrl }}?
  
  In my .env file I have
  
  ```
  DEFAULT_SITE_URL="https://www.mysite.com"
  
  ```
  
  but
  
  ```
  {{ craft.app.request.absoluteUrl() }}
  
  ```
  
  only outputs <https://mysite.com> without the "www". How can I fix that?
  
  **Tags:** url, siteurl, env
  
  > **Comments:**
  > **username_1**: Craft will listen on whatever vhost you give it. Is your web server setup to redirect non-www to www?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2021-06-21. Score: 2
  
  *Maybe there's a better solution but:*
  
  `{{ craft.app.request.absoluteUrl()|replace({'https://': "https://www."}) }}`
  
  <https://twig.symfony.com/doc/3.x/filters/replace.html>
  
  > **Comments:**
  > **username_0**: That works nicely, thank you!  
  
  ---
  
  