Apache 重定向(到另一个域/服务器上的单个页面)不起作用

Apache 重定向(到另一个域/服务器上的单个页面)不起作用

我想设置从一组子页面到另一个 URL 的重定向,但不起作用。是因为它不在同一台机器/网络上(其他东西)吗?我应该在原始服务器上添加其证书吗?

我试过 :

Redirect /subpage https://another-url-i-own.net/page1/page2

或者

Redirect /subpage/.* https://another-url-i-own.net/page1/page2

或者

Redirect /subpage/* https://another-url-i-own.net/page1/page2

或者使用永久重定向或 301 重定向等

击倒

您能启发我吗?

=> apache 配置文件:

DirectoryIndex index.php index.html


<VirtualHost *:80>
ServerName mydomain.org
DocumentRoot "/var/www"

Redirect /servicedesk/.* newdomain.org

<Directory "/var/www">
    AllowOverride All
    Options -Indexes +FollowSymLinks
    Require all granted
</Directory>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^mydomain.org$
RewriteRule ^.*$ https :// mydomain.org%{REQUEST_URI} [L]
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !=/server-status
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

</VirtualHost>


<VirtualHost *:443>
ServerName mydomain.org
DocumentRoot "/var/www"

Redirect /servicedesk/.* newdomain.org

SSLEngine on
#SSLCipherSuite AES256+EECDH:AES256+EDH
SSLProtocol All -SSLv2 -SSLv3
SSLHonorCipherOrder On
SSLCompression off
SSLCertificateFile /etc/ssl/certs/mydomain.org.cer
SSLCertificateKeyFile /etc/ssl/certs/mydomain.org.key
SSLCertificateChainFile /etc/ssl/certs/cacerts-mydomain.org.cer

<Directory "/var/www">
    AllowOverride All
    Options -Indexes +FollowSymLinks
    Require all granted
</Directory>
ErrorDocument 503 /html/maintenance_hosting.html
SSLProxyEngine  On
ProxyRequests   Off
ProxyPreserveHost       On
TimeOut 600
KeepAliveTimeout 600
<Proxy *>
                Require all granted
</Proxy>
ProxyRequests           Off
ProxyPreserveHost       On
ProxyPass               /html   !
ProxyPass               /server-status  !

<Location /server-status>
        SetHandler server-status
        Order deny,allow
        Deny from all
        Allow from localhost
</Location>

ProxyPass               /       http://localhost:8080/
ProxyPassReverse        /       http://localhost:8080/

ErrorLog /randomfolder/apache2/log/error.log
CustomLog /randomfolder/apache2/log/access.log combined

Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains;"

</VirtualHost>

答案1

您的第二个例子非常正确,只是您需要使用RedirectMatch而不是Redirect

RedirectMatch /subpage/.* https://another-url-i-own.net/page1/page2

相关内容