dongtui9168 2015-01-14 15:39
浏览 119

vHost和SSL中的mod_rewrite

Im searching the whole web but i dont find a solution for my problem.

My server is debian 7.7 with apache2.2. I have a lot of vhost and one SSL cert. All Domains are pointing to the same directory (/var/www/www). For example i have the following domains:

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

I would moving all .htaccess stuff to their vhost.

First of all i would redirect www.domain.gv.at www.domain.at domain.gv.at domain.at to https. My .htaccess file looks like that:

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]

also I would like pretty URL (i.e. https://www.domain.at/cool/page) so i have the following in my .htaccess

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

Now I'm trying to copy all in my vHost config without success. My vHost (port 80) looks like that:

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

my vhost for 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>

But it doesn't work. Some ideas?

Goals - delete .htaccess (I don't want to use it) - redirect domain.at and domain.gv.at to https:// - use pretty urls for typo3

thanks allot

  • 写回答

1条回答 默认 最新

  • dongzituo5530 2015-01-19 07:07
    关注

    i could solve the problem. In my case the directory was wrong. I have no idea why but it works now after i remove the in the vHost (SSL and "normal")

    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法