Apache HTTP Server: Difference between revisions

From lurkmore wiki
Jump to navigationJump to search
No edit summary
m 2 revisions imported
 
(No difference)

Latest revision as of 23:15, 31 March 2022

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.