Redirect domains without www (e.g. domain.com) to www.domain.com with apache rewrite rules

If all your visitors shall access your website with a URL like www.domain.com and not without www, use the following apache rewrite rule for redirecting them.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www
RewriteRule (.*) http://www.%{HTTP_HOST}$1 [L,R]

The apache rewrite rule can be added in a .htaccess file in the website root directory or if you use ISPConfig 2 or 3, you can also add the rewrite rule into the apache directives field of the website.

Sponsored

The post Redirect domains without www (e.g. domain.com) to www.domain.com with apache rewrite rules appeared first on FAQforge.

Ubuntu Server Admin

Recent Posts

Native integration now available for Pure Storage and Canonical LXD

June 25th, 2025 – Canonical, the company behind Ubuntu, and Pure Storage, the IT pioneer…

19 hours ago

Revolutionizing Web Page Creation: How Structured Content is Slashing Design and Development Time

Co-authored with Julie Muzina A year ago, during our Madrid Engineering Sprint, we challenged ourselves…

2 days ago

Ubuntu Weekly Newsletter Issue 897

Welcome to the Ubuntu Weekly Newsletter, Issue 897 for the week of June 15 –…

2 days ago

Ubuntu Core is now available on MediaTek’s Genio platform

This is the first optimized Ubuntu Core image available on MediaTek’s Genio 350, 510, 700,…

3 days ago

Effective infrastructure automation to reduce data center costs

Data centers are expensive: automation is the solution Today, managing a data center requires striking…

6 days ago

What are our partners building for device makers? Explore the highlights from Ubuntu IoT Day Singapore

Our first Ubuntu IoT Day in Southeast Asia – and our first ever event in…

7 days ago