Apache HTTP Server

From lurkmore wiki
Revision as of 06:45, 28 September 2016 by Kyrio (talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Apache HTTP Server, or just Apache, is the most popular web server being used.

Redirect all traffic to www subdomain

Rather than being accessed on the root domain (lurkmore.com) and www subdomain (www.lurkmore.com) at the same time, redirect all traffic to a single www subdomain.

In your Apache VirtualHost config:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

If you require https access on the domain:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Using this version will enforce https along with the www subdomain.