I
I
ilya_k2016-01-24 19:52:15
htaccess
ilya_k, 2016-01-24 19:52:15

Redirect from mysite.ru to www.mysite.ru doesn't work through 301 via .htaccess?

Good afternoon, I ask you to tell me,
the current contents of the .htaccess file, the commented lines are attempts to write a redirect differently, which also failed.
I ask you to clarify in my head, otherwise something is completely confused.
The IP registrar has the same address for both domains (www.mysite.ru; mysite.ru).
Options All -Indexes
ErrorDocument 403 /error/403.html
ErrorDocument 404 /error/404.html
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite.ru
RewriteRule (.*) www.mysite.ru/$1 [R=301 ,L]
#RewriteCond %{HTTP_HOST} ^mysite.ru$ [NC]
#RewriteRule ^(.*)$ www.mysite.ru/$1 [R=301,L]
#RewriteCond %{HTTP_HOST} ^([^www].*)$
#RewriteRule ^(.*)$ http://www.%1/$1 [L,R=301]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
ilya_k, 2016-01-24
@ilya_k

I'll answer myself.
you need to check
/etc/apache2/apache2.conf
for the presence of AllowOveride All in it,
check if mod_rewrite is enabled in your Apache,
sudo a2enmod rewrite
if not, then you need to restart the Apache service after that,
then add the following entries to the .htaccess file
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^mysite.ru [NC]
RewriteRule ^(.*)$ www.mysite.ru/$1 [L,R=301]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question