-1

I have two domains named www.example.com and www.example-alias.com , Both domain are pointing same location in the server. I need to do 301 redirection for www.example.com to www.example-alias.com

<IfModule mod_rewrite.c>
RewriteEngine On        
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com [NC]
RewriteRule ^(.*)$ http://www.example-alias.com/$1 [R=301,L]
</IfModule>

It is working only for www.example.com home page, not for any inner page. How do I redirect www.example.com inner pages to www.example-alias.com. Similar

www.example.com/service to www.example-alias.com/service
sathish
  • 1
  • 1
  • 3

1 Answers1

0

I ca not test it now, but try this out.

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.example\.com(/|$) [NC]
RewriteRule ^(.*)$ http://www.example-alias.com/$1 [R=301,L]

or

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example-alias.com/$1 [R=301,L]
Max Muster
  • 297
  • 1
  • 5
  • 26