Quiron
Quiron

Reputation: 370

Redirect from one URL to another

I have following 2 URLs:

I need these both redirections:

I am new using htaccess, and I tried this but doesn't work:

RewriteCond %{HTTP_HOST} ^www.xxxprevencion.es$ [NC]
RewriteRule ^(.*)$ http://www.xxxassistance.es/$1 [L,R=301]

RewriteCond %{HTTP_HOST} ^www.xxxprevencion.com$ [NC]
RewriteRule ^(.*)$ http://www.xxxassistance.com/$1 [L,R=301]

Upvotes: 0

Views: 59

Answers (1)

Drakes
Drakes

Reputation: 23670

I'm not entirely sure what you are trying to achieve, but here are two scenarios I wrote solutions for. Try one of these in .htaccess depending on what you need:

www.yyyprevencion.es -> www.xxxassistance.es
www.yyyprevencion.com -> www.xxxassistance.com

# www.yyyprevencion.es --> www.xxxassistance.es
RewriteCond %{HTTP_HOST} ^(www\.)?yyyprevencion\.es$ [NC]
RewriteRule ^(.*)$ http://www.xxxassistance.es/$1 [L,R=301]

# www.yyyprevencion.com --> www.xxxassistance.com
RewriteCond %{HTTP_HOST} ^(www\.)?yyyprevencion\.com$ [NC]
RewriteRule ^(.*)$ http://www.xxxassistance.com/$1 [L,R=301]

www.xxxprevencion.es -> www.xxxassistance.es
www.xxxprevencion.com -> www.xxxassistance.com

# www.xxxprevencion.es --> www.xxxassistance.es
RewriteCond %{HTTP_HOST} ^(www\.)?xxxprevencion\.es$ [NC]
RewriteRule ^(.*)$ http://www.xxxassistance.es/$1 [L,R=301]

# www.xxxprevencion.com --> www.xxxassistance.com
RewriteCond %{HTTP_HOST} ^(www\.)?xxxprevencion\.com$ [NC]
RewriteRule ^(.*)$ http://www.xxxassistance.com/$1 [L,R=301]

Experiment here: http://htaccess.madewithlove.be/

Upvotes: 2

Related Questions