Apache HTTP Server: Difference between revisions

From lurkmore wiki
Jump to navigationJump to search
No edit summary
 
No edit summary
Line 1: Line 1:
'''Apache HTTP Server''', or just '''Apache''', is the most popular web server being used.
'''Apache HTTP Server''', or just '''Apache''', is the most popular web server being used. It can be used on [[Linux]], [[Windows]], and many other operating systems.


== Redirect all traffic to www subdomain ==
== Redirect all traffic to www subdomain ==

Revision as of 12:33, 7 February 2017

Apache HTTP Server, or just Apache, is the most popular web server being used. It can be used on Linux, Windows, and many other operating systems.

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.