Multisite .htaccess simple redirection

时间:2017-02-28 13:22:33

标签: .htaccess

I have 2 domain names pointing to same Web root host folder, so sharing the same .htaccess file, too.

I'm trying that www.domain1.com/blog redirects to www.domain2.com/blog. All without afecting www.domain2.com/blog requests, ponting to same .htaccess file, because on that case we enter in a infinite loop :-)

Just to understand me, in programming it would be something like:

    if ( (domain=='www.domain1.com') && (folder='/blog/') ) {
    redirect to 'http://www.domain2.com/blog/'
    }

I'm sure it simple, but I don't get it... Thank you so much to all of you!

UPDATE:

finally I did it with that code:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} domain1.com
    RewriteCond %{REQUEST_URI} !^/blog
    RewriteRule .* http://www.domain2.com/blog [R=301,L]
    </IfModule>

1 个答案:

答案 0 :(得分:0)

你可以这样做:

RewriteCond %{HTTP_HOST}    ^www\.domain1\.com$ [NC] 
RewriteRule ^blog$ www.domain2.com/blog [NC,L,QSA,NS]

这应该有用。