문제

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

도움이 되었습니까?

해결책

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).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top