【问题标题】:Apache Virtualhost Redirect in specific folders特定文件夹中的 Apache Virtualhost 重定向
【发布时间】:2022-01-09 22:43:51
【问题描述】:

我的问题是在特定文件夹中重定向:

首先:所有http://myDomain.de 必须更改为https://myDomain.de ...这不是问题 当电话是:https://myDomain.de/kd 我可以重定向到https://myDomain.de/kd/ ..这是工作

我的问题是:

当我打电话时:https://myDomain.de 我不会重定向到文件夹 https://myDomain.de/sub1(这是我的 wordpress 文件...)

这是我的代码:

<VirtualHost *:80>
    Redirect permanent  /kd https://myDomain.de/kd/ 

    Redirect permanent  /   https://myDomain.de/sub1/
</VirtualHost>

<VirtualHost _default_:443>
    ServerAdmin masterddgdgg@gmx.de
    ServerName myDomain.de
    
    DocumentRoot /var/www/html
    

    ErrorLog ${APACHE_LOG_DIR}/myDomain.de-error.log
    CustomLog ${APACHE_LOG_DIR}/myDomain.de-access.log combined

    <IfModule mod_ssl.c>
        SSLCertificateFile /etc/letsencrypt/live/myDomain.de-0001/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/myDomain.de-0001/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf
    </IfModule>

</VirtualHost>


<Directory "/var/www/html">
    Options -Indexes +FollowSymLinks +MultiViews
    AllowOverride All
    Require all granted
</Directory>

【问题讨论】:

    标签: redirect ssl-certificate virtualhost


    【解决方案1】:

    用这个替换你的Redirects

    RewriteEngine On
    
    RewriteRule %{REQUEST_URI} !/kd
    RewriteRule ^/?$ https://myDomain.de/sub1/ [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-16
      • 2017-02-17
      • 2019-01-15
      • 2017-09-08
      • 2018-03-08
      • 1970-01-01
      • 2019-03-07
      • 2023-04-01
      相关资源
      最近更新 更多