Domanda

I have a domain name and an alias which look like this : mydomain.com mydomain.ca

I want to create a redirection. When a user write mydomain.com, I would like to be redirect on mydomain.ca.

I tried this code but it don't seem to work with what I want to do : here

È stato utile?

Soluzione

The solution is very simple - use the Redirect directive.

Example:

Redirect permanent / http://mydomain.ca

This code should go in your .htaccess file and be uploaded to the root of mydomain.com.

Alternatively, if they're on the same virtual host, you can usemod_rewrite:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^mydomain\.com$
RewriteRule ^ http://mydomain.ca%{REQUEST_URI} [L,R=301]

The R flag also indicates the HTTP status code (301 - Moved Permanently).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top