Apache Виртуальный хост, не работающий на www домены

Я пытаюсь перенаправить для доступа к сайту с URL: www.example.com, но это дает мне 403 запрещенных. сайт работает с example.com, https://www.example.com https://example.com

вот мой виртуальный хост:

<VirtualHost :*80>
    ServerName www.example.com
    ServerAlias example.com
    DocumentRoot /home/asd/sites/example.com/public_html


  <Directory /home/asd/sites/example.com/public_html>
    AllowOverride all
    Options Indexes FollowSymLinks Includes ExecCGI
   Require all granted
  </Directory>

</VirtualHost>
 <VirtualHost *:443>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    ServerName  example.com
    ServerAlias www.example.com

    ServerAdmin  example.com@gmail.com
    DocumentRoot /home/asd/sites/example.com/public_html


    SSLEngine On
    SSLCertificateFile /home/asd/ssl_certs/example.com.crt
    SSLCertificateKeyFile /home/asd/ssl_certs/example.com.key
    SSLCACertificateFile /home/asd/ssl_certs/example.com.intermediate.crt


<Directory /home/asd/sites/example.com/public_html>
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^(www\.)(.*) [NC]
    RewriteRule (.*) https://%2%{REQUEST_URI} [L,R=301]

    AllowOverride all
    Options Indexes FollowSymLinks Includes ExecCGI
   Require all granted
</Directory>

Я попытался включить и отключить 000-default.conf также. но если я включаю это затем, www.example переходит к апачскому корневому index.html

https://www.example.com хорошо работает все же.

Я пытался заставить его работать в течение многих часов, но я не могу сделать так. Любая справка будет цениться.

Я хочу весь трафик, идут от не http к https и www к не www.

Спасибо!

1
задан 9 September 2018 в 18:22

1 ответ

Выпущенный, что это была опечатка. Потраченный на мой целый день, выясняя проблему.

Это было:

 <VirtualHost :*80>

который должен быть:

 <VirtualHost *:80>
0
ответ дан 7 December 2019 в 23:21

Другие вопросы по тегам:

Похожие вопросы: