簡體   English   中英

vHost和SSL中的mod_rewrite

[英]mod_rewrite in vHost and SSL

我在整個網上搜索,但我找不到解決方案。

我的服務器是apache2.2的debian 7.7。 我有很多虛擬主機和一個SSL證書。 所有域都指向同一目錄(/ var / www / www)。 例如,我有以下域:

  • www.domain.gv.at
  • www.domain.at
  • www.example.at
  • www.anotherexample.at

我會將所有.htaccess內容移至他們的虛擬主機。

首先,我要將www.domain.gv.at重定向到www.domain.at domain.gv.at domain.at到https。 我的.htaccess文件如下所示:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.domain\.gv\.at [NC,OR]
RewriteCond %{HTTP_HOST} ^domain\.gv\.at [NC,OR]
RewriteCond %{HTTP_HOST} ^domain\.at [NC]
RewriteRule ^(.*)$ https://www.domain.at/$1 [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]

我也想要漂亮的URL(即https://www.domain.at/cool/page ),所以我的.htaccess中有以下內容

RewriteRule ^/typo3$ - [L]
RewriteRule ^/typo3/.*$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* /index.php

現在,我嘗試將所有內容復制到我的vHost配置中,但沒有成功。 我的vHost(端口80)如下所示:

<VirtualHost *:80>
    ServerName www.domain.at
    ServerAlias domain.at domain.gv.at www.domain.gv.at

    DocumentRoot /var/www/www/
    ErrorLog /var/log/apache2/www.domain.at-error.log
    CustomLog /var/log/apache2/www.domain.at-access.log vhost_combined_ip

    <Directory /var/www/www>
      Options -Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      allow from all

      RewriteEngine On
      RewriteCond %{HTTP_HOST} ^www\.domain\.gv\.at [NC,OR]
      RewriteCond %{HTTP_HOST} ^domain\.gv\.at [NC,OR]
      RewriteCond %{HTTP_HOST} ^domain\.at [NC]
      RewriteRule ^(.*)$ https://www.domain.at/$1 [R=301,L]

      RewriteCond %{HTTPS} !=on
      RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]

RewriteRule ^/typo3$ - [L]
RewriteRule ^/typo3/.*$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* /index.php


    </Directory>
</VirtualHost>

我的ssl虛擬主機

<VirtualHost *:443>
    SSLEngine On
    SSLCertificateFile /etc/apache2/ssl/domain.crt
    SSLCertificateKeyfile /etc/apache2/ssl/domain.key
    SSLCertificateChainFile /etc/apache2/ssl/COMODOSSLCA.crt

    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
    SSLProtocol ALL -SSLv2
    SSLHonorCipherOrder On
    SSLCipherSuite AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH
    SSLInsecureRenegotiation off

    ServerName www.domain.at
    ServerAlias domain.at domain.gv.at www.domain.gv.at *.domain.at

    DocumentRoot /var/www/www/
    ErrorLog /var/log/apache2/domain.at-error.log
    CustomLog /var/log/apache2/domain.at-access.log combined

    <Directory /var/www/www>
      Options FollowSymLinks MultiViews -Indexes
      AllowOverride All
      Order allow,deny
      allow from all
    </Directory>
</VirtualHost>

但這是行不通的。 有什么想法嗎?

目標-刪除.htaccess(我不想使用它)-將domain.at和domain.gv.at重定向到https://-為typo3使用漂亮的url

謝謝分配

我可以解決問題。 就我而言,目錄錯誤。 我不知道為什么,但是在刪除vHost中的SSL(“ SSL”和“ normal”)后,它現在可以工作了

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM