Apache 重定向(到另一個網域/伺服器上的單一頁面)不起作用

Apache 重定向(到另一個網域/伺服器上的單一頁面)不起作用

我想設定僅從一組子頁面到另一個網址的重定向,但它不起作用。是因為它不在同一台機器/網路上(其他原因)嗎?我應該在來源伺服器上新增其憑證嗎?

我試過 :

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 等

KO

您能賜教一下嗎?

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

相關內容