Z
Z
zi2015-12-01 10:17:16
Search Engine Optimization
zi, 2015-12-01 10:17:16

How to redirect from .ru domain to .com, but leave one directory available at .ru address?

there is a site xxx, it has 2 domains, xxx.ru and xxx.com, the main domain was xxx.com, you need to redirect from ru to com, but it's all simple, the main problem is that you need to leave the xxx directory available. ru/folder/, how to make such an exception?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
IceJOKER, 2015-12-01
@IceJOKER

RewriteEngine on
RewriteCond %{HTTP_HOST} ru$
RewriteCond %{REQUEST_URI} !^/folder/?
RewriteRule (.*?) http://xxx.com/$1 [NC,L,R=301]

E2pkXMxCVKdzmY.pngbmoOnBXHoR6Bmy.png

Z
zi, 2015-12-02
@zi

The rules are now:

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On

  RewriteCond %{HTTP_HOST} ^site.ru$
  RewriteCond %{REQUEST_URI} !^/lp/?
  RewriteRule (.*?) http://site.com/$1 [R=301,L]

  # редирект /news/123 -> /news/123/
  RewriteCond %{REQUEST_URI} ^(.*/[^/\.]+)$
  RewriteRule ^(.*)$ /$1/ [R=301,L]

  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-l
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !/bitrix/urlrewrite.php$
  RewriteRule ^(.*)$ /bitrix/urlrewrite.php [L]
  RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>

If you type site.ru/test/ , then you are redirected to site.com .... although the service shows that everything is OK

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question