Php vHost和SSL中的mod_重写

Php vHost和SSL中的mod_重写,php,apache,.htaccess,mod-rewrite,ssl,Php,Apache,.htaccess,Mod Rewrite,Ssl,我搜索了整个网页,但我没有找到解决问题的方法 我的服务器是Debian7.7和apache2.2。我有很多vhost和一个SSL证书。所有域都指向同一个目录(/var/www/www)。例如,我有以下域: www.domain.gv.at www.domain.at www.example.at www.anotherexample.at 我会把所有的.htaccess的东西移到他们的vhost 首先,我将www.domain.gv.at www.domain.at domain.gv.at

我搜索了整个网页,但我没有找到解决问题的方法

我的服务器是Debian7.7和apache2.2。我有很多vhost和一个SSL证书。所有域都指向同一个目录(/var/www/www)。例如,我有以下域:

  • www.domain.gv.at
  • www.domain.at
  • www.example.at
  • www.anotherexample.at
我会把所有的.htaccess的东西移到他们的vhost

首先,我将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]
<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>
此外,我想漂亮的网址(即),所以我有以下在我的.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)如下所示:

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]
<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>

服务器名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\u combined\u ip
选项-索引跟随符号链接多视图
允许超越所有
命令允许,拒绝
通融
重新启动发动机
在[NC,或]处重写cond%{HTTP_HOST}^www\.domain\.gv\
在[NC,或]
在[NC]处重写cond%{HTTP_HOST}^domain\
重写规则^(.*)$https://www.domain.at/$1[R=301,L]
重写cond%{HTTPS}=在…上
重写规则^/?(*)https://%{SERVER_NAME}/$1[R=301,L]
重写规则^/typo3$-[L]
重写规则^/typo3/*$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-L
重写规则。*/index.php
我的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>

斯伦金安
SSLCertificateFile/etc/apache2/ssl/domain.crt
SSLCertificateKeyfile/etc/apache2/ssl/domain.key
SSLCertificateChainFile/etc/apache2/ssl/COMODOSSLCA.crt
SetEnvIf用户代理“*MSIE.*”无保留ssl未清理关闭
SSLProtocol ALL-SSLv2
SSLHonorCipherOrder开启
SSLCipherSuite AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:RC4:高:!MD5:!阿努尔:!EDH
SSL安全协商关闭
服务器名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组合
选项如下符号链接多视图-索引
允许超越所有
命令允许,拒绝
通融
但它不起作用。一些想法

目标 -delete.htaccess(我不想使用它) -将domain.at和domain.gv.at重定向到https:// -对typo3使用漂亮的URL


谢谢你,我能解决这个问题。就我而言,目录是错的。我不知道为什么,但在我删除vHost中的(SSL和“正常”)后,它现在可以工作了