M
M
Maxim2015-01-24 05:05:48
Drupal
Maxim, 2015-01-24 05:05:48

Multisite in Drupal 7. How to redirect from subdomain name.site.ru to name.ru?

There is a main site - site.ru All sites are stored in the sites
directory . In this directory, for each site, a folder of the form name.site.ru is created , and a line of the form is written in the sites.php file . When the site is opened at the address name.site.ru, name.site.ru opens. When you open the same site at name.ru, name.ru opens. How to redirect from name.site.ru to name.ru? (For the subdomain to fully refer to the domain) The sites/name.site.ru/ directory contains the settings.php file and the files , modules , themes folders .
$sites['name.ru'] = 'name.site.ru';


As far as I understand, the way to register a redirect in .htaccess to the root is not suitable, because. this is for the single site case.
I suppose that it might be worth creating a .htaccess file in the folder of a specific site (for example, in sites/name.site.ru ). I tried to do this, but the redirect didn't work, it just turned off the css styles.
Help me please. This factor already hinders SEO on several sites.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2015-01-25
@MToUCH

It worked! I found .htaccess in the root, inserted after

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On

your code
RewriteCond %{HTTP_HOST} ^armadio.vtopmaster.ru
RewriteRule (.*) http://armadio-dv.ru/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^dalrezerv.vtopmaster.ru
RewriteRule (.*) http://chelovekpesok.ru/$1 [R=301,L]

I decided to try 2 sites at once, and it worked. Thanks Emil for the tip!

E
Emil Aliev, 2015-01-24
@Aliev-Emil

Can you clarify?
When you open a site at name.site.ru, does the directory sites/name.site.ru/ open?
When you open a site at name.ru, does the directory sites/name.site.ru/ open?
____________________________________________________
Check if there is an .htaccess file in the root directory of site.ru.
If the file exists, then add the following lines to the mod_rewrite () section in it

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

If the file does not exist then create it with the following content
<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On

  RewriteCond %{HTTP_HOST} ^name.site.ru
  RewriteRule (.*) http://name.ru/$1 [R=301,L]
</IfModule>

This is done in the root site, since you are not redirecting from all domains to one, but from one specific domain to another. Those. for all other domains, this rule will simply be ignored.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question