簡體   English   中英

如何在不更改URL的情況下重定向網頁(使用Apache VirtualHost)

[英]How to redirect a web page while not changing the URL (using Apache VirtualHost)

我正在Apache Web服務器中設置虛擬主機,並且已經有一些規則,可以執行從一個URL到另一個URL的簡單301重定向。 但是,現在有人問我是否可以編寫一個重定向到另一個頁面的規則,同時保持URL不變,所以我嘗試了以下方法:

<VirtualHost *:80>
ServerName ZZZ.com
ServerAlias YYY.com ZZZ.com
Redirect / YYY.com
</VirtualHost>

和這個:

<VirtualHost *:80>
ServerName ZZZ.com
RewriteEngine  on
RewriteRule ^/(.*) YYY.com/$1 [R]
</VirtualHost>

我對他們的期望也沒有。 他們在我看來錯了,但我只是在任何地方都找不到任何有用的信息。 我看過http://httpd.apache.org/docs/2.4/vhosts/examples.htmlhttp://httpd.apache.org/docs/current/mod/mod_rewrite.html-他們都不是有幫助的。

<VirtualHost *:80>
ServerName YYY.com
ServerAlias ZZZ.com
RewriteEngine  on
RewriteCond %{HTTP_HOST} !^yyy\.com$ [NC]
RewriteRule (.*) YYY.com$1 [R=302,L]
</VirtualHost>

您錯過了阻止其重定向正確URL的條件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM