Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: httpd.conf directive for 301 domain.com to www.domain.com |
|
Author |
|
consultant
Joined: 29 Mar 2011 Posts: 4
|
Posted: Mon 11 Jan '16 18:52 Post subject: httpd.conf directive for 301 domain.com to www.domain.com |
|
|
All my sites domain.com doesn't do a 301 redirect to www.domain.com. Rather than correcting this in the .htaccess file of each site, I'd like to add a directive in the global pre-include file that is included with the httpd.conf file of each site but I'm not an Apache httpd.conf expert (obviously) Can the redirect be setup there and if so what is the syntax? I've googled like crazy and can't find an example. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Wed 13 Jan '16 13:22 Post subject: |
|
|
force www in a vhost
Code: |
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
|
|
|
Back to top |
|
|
|
|
|
|