Apache modrewrite for vhost 适用于所有 vhost

Apache modrewrite for vhost 适用于所有 vhost

我在 sites-available 上有三个单独的 dvhost 配置,其中一个包含:

RewriteEngine On
RewriteRule ^/$ /app/login.axvw [R]

主要问题是它也将所有其他 vhost 根重定向到 /app/login.axvw。

完整虚拟主机配置:

编辑。添加一个虚拟主机的完整配置:

<VirtualHost *:80>
    ServerName sub.domain.com
    ServerAlias sub.domain

        redirect / https://sub.domain.com/app/login.axvw

        ErrorLog ${APACHE_LOG_DIR}/sub.domain_error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/sub.domain_access.log combined

</VirtualHost>

<VirtualHost *:443>
        ServerName sub.domain.com

        SSLEngine on
        SSLCertificateFile    /etc/apache2/ssl.crt/domain.com.crt
        SSLCertificateKeyFile /etc/apache2/ssl.key/domain.com.key
        SSLCertificateChainFile /etc/apache2/ssl.crt/gd_bundle.crt

RewriteEngine On
RewriteRule ^/$ /app/login.axvw [R]

#       redirect / https://sub.domain.com/app/login.axvw
    ProxyRequests Off

    ProxyPass / ajp://sub.domain.com:8009/
    ProxyPassReverse / https://sub.domain.com

    <Location />
        Order allow,deny
        Allow from all
    </Location>

        ErrorLog ${APACHE_LOG_DIR}/sub.domain_error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/sub.domain_access.log combined


</VirtualHost>

答案1

放弃重写,改用 Redirectmatch;当事情变得真的有趣的。

Redirectmatch ^/$ https://sub.domain.com/app/login.axvw

相关内容