2009-08-21 35 views
29
靜態頁面

我想重定向所有請求爲mydomain.com他們是否是這樣的:重定向一個域名下的所有請求

將被重定向到

只要有mydomain.com的話,他們應該看到這個頁面 - 它是一個我們很快就會回來的消息。

我應該使用.htaccess還是conf?怎麼樣?

+5

這是爲什麼關閉主題?太糟糕了,我不能投出任何重新開放的選票呢。 – bjb568 2013-10-23 01:10:25

+1

現在,我可以(浩瀚),碰撞。 – bjb568 2014-05-14 06:53:11

+0

@ bjb568 yea誰知道;顯然在SO上有這樣的問題專門有多個標籤。我可以理解,人們可能會傾向於在服務器上有這個缺陷,但將其稱爲超出範圍,是對權威和常識的濫用。 \ o/ – 2016-03-01 16:56:51

回答

46

其實我最終找到的ServerFault答案:

https://serverfault.com/questions/32513/url-redirect-to-another-page-on-the-same-site

「這個例子將302重定向所有URL爲 「/underconstruction.html」:

RewriteEngine On 
RewriteCond %{REQUEST_URI} !=/underconstruction.html 
RewriteRule^/underconstruction.html [R=302] 

(意爲「如果URI不是/underconstruction.html,則重定向到/underconstruction.html」)「 - Tommeh

+1

如果這不起作用,請嘗試將''配置。然後重新啓動apache(在linux上:/etc/init.d/httpd restart) – 2011-09-27 10:15:58

相關問題