S
S
Sergey Goryachev2017-01-12 23:12:28
Apache HTTP Server
Sergey Goryachev, 2017-01-12 23:12:28

Apache not-WWW to WWW redirect?

How to make a redirect in Apache config?
Now the config from ISPmanager is used, it has https.
It is necessary that the site.ru, www.site.ru, https://site.ru and https://www.site.ru domains always open https://www.site.ru .

<VirtualHost 185.105.224.32:80>
  ServerName site.ru
  DocumentRoot /var/www/site/data/www/site.ru
  ServerAdmin [email protected]
  AddDefaultCharset off
  AssignUserID site site
  CustomLog /var/www/httpd-logs/site.ru.access.log combined
  ErrorLog /var/www/httpd-logs/site.ru.error.log
  <FilesMatch "\.ph(p[3-5]?|tml)$">
    SetHandler application/x-httpd-php5
  </FilesMatch>
  ScriptAlias /php-bin/ /var/www/php-bin-isp-php70/site/
  AddHandler application/x-httpd-php5 .php .php3 .php4 .php5 .phtml
  Action application/x-httpd-php5 /php-bin/php
  ServerAlias www.site.ru
  DirectoryIndex index.html index.php
</VirtualHost>
  <FilesMatch "\.ph(p[3-5]?|tml)$">
    SetHandler application/x-httpd-php
  </FilesMatch>
  <FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
  </FilesMatch>
<Directory /var/www/site/data/www/site.ru>
  Options +Includes -ExecCGI
  RewriteEngine on
  RewriteCond %{HTTPS} off
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</Directory>
<VirtualHost 185.105.224.32:443>
  ServerName site.ru
  DocumentRoot /var/www/site/data/www/site.ru
  ServerAdmin [email protected]
  AddDefaultCharset off
  SSLEngine on
  SSLCertificateFile "/var/www/httpd-cert/site/site.ru_le1.crt"
  SSLCertificateKeyFile "/var/www/httpd-cert/site/site.ru_le1.key"
  SSLHonorCipherOrder on
  SSLProtocol +TLSv1 +TLSv1.1 +TLSv1.2
  SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH 
  AssignUserID site site
  CustomLog /var/www/httpd-logs/site.ru.access.log combined
  ErrorLog /var/www/httpd-logs/site.ru.error.log
  <FilesMatch "\.ph(p[3-5]?|tml)$">
    SetHandler application/x-httpd-php5
  </FilesMatch>
  SSLCertificateChainFile "/var/www/httpd-cert/sveaborg/site.ru_le1.ca"
  ScriptAlias /php-bin/ /var/www/php-bin-isp-php70/site/
  AddHandler application/x-httpd-php5 .php .php3 .php4 .php5 .phtml
  Action application/x-httpd-php5 /php-bin/php
  ServerAlias www.site.ru
  DirectoryIndex index.html index.php
</VirtualHost>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Goryachev, 2017-01-13
@webirus

I solved it through Nginx linuxguru.ru/administration/pravelnyj-redirekt-sh...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question