summaryrefslogtreecommitdiff
path: root/apache2/conf-available/local-html5-www-add.conf
blob: c7a9fb8a391f668c2424f60b9bbb64c1e0088317 (plain)
  1. # Apache Server Configs v2.14.0 | MIT License
  2. # https://github.com/h5bp/server-configs-apache
  3. # ----------------------------------------------------------------------
  4. # | Suppressing / Forcing the `www.` at the beginning of URLs |
  5. # ----------------------------------------------------------------------
  6. # The same content should never be available under two different
  7. # URLs, especially not with and without `www.` at the beginning.
  8. # This can cause SEO problems (duplicate content), and therefore,
  9. # you should choose one of the alternatives and redirect the other
  10. # one.
  11. #
  12. # By default `Option 1` (no `www.`) is activated.
  13. # http://no-www.org/faq.php?q=class_b
  14. #
  15. # If you would prefer to use `Option 2`, just comment out all the
  16. # lines from `Option 1` and uncomment the ones from `Option 2`.
  17. #
  18. # (!) NEVER USE BOTH RULES AT THE SAME TIME!
  19. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  20. # Option 1: rewrite www.example.com → example.com
  21. #<IfModule mod_rewrite.c>
  22. # RewriteEngine On
  23. # RewriteCond %{HTTPS} !=on
  24. # RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  25. # RewriteRule ^ %{ENV:PROTO}://%1%{REQUEST_URI} [R=301,L]
  26. #</IfModule>
  27. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  28. # Option 2: rewrite example.com → www.example.com
  29. #
  30. # Be aware that the following might not be a good idea if you use "real"
  31. # subdomains for certain parts of your website.
  32. <IfModule mod_rewrite.c>
  33. RewriteEngine On
  34. RewriteCond %{HTTPS} !=on
  35. RewriteCond %{HTTP_HOST} !^www\. [NC]
  36. RewriteCond %{SERVER_ADDR} !=127.0.0.1
  37. RewriteCond %{SERVER_ADDR} !=::1
  38. RewriteRule ^ %{ENV:PROTO}://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  39. </IfModule>