0

I currently have the following in my config file:

ServerName example.com
ServerAlias www.example.com
ServerAlias www.example.org
ServerAlias www.example.co.uk

This all works great because if I go to www.example.org/something I get redirected to http://example.com/something The only problem is that the redirection that occurs is "temporary" ie: 302 instead of 301.

How can I change this so that it will be a 301 instead while still using the very popular ServerAlias command?

John Crawford
  • 2,005
  • 3
  • 15
  • 9

1 Answers1

0

I don't think the 302 was generated by Apache.

You can do a 301 with something like this in your Apache configuration :

RewriteEngine   On
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^exemple\.com [NC]
RewriteRule ^ http%{ENV:protossl}://exemple.com%{REQUEST_URI} [L,R=301]
Sylvain Firmery
  • 331
  • 1
  • 4