2012-03-27 85 views
0

我想推送所有發送請求到特定子目錄的用戶返回主頁。例如。;將所有請求重寫到主頁的特定子目錄

http://test.example.com/apps/ 
http://test.example.com/apps/sd1 
http://test.example.com/apps/fjwoiejf/jiejn 

都應該重寫:

http://test.example.com 

Web服務器就是Apache。

回答

0

當然在test.example.com所在的根目錄htaccess文件:

RewriteEngine on 
RewriteRule ^apps/(.*) http://test.example.com [R=301,L] 

此外,如果你想:

RewriteEngine on 
RewriteRule ^apps/(.*) http://test.example.com/my_new_app_directory/$1 [R=301,L] 

甚至:

RewriteEngine on 
RewriteRule ^apps/(.*) http://test.example.com/sorry_dude_this_does_not_exist.php?file=$1 [R=301,L] 
+0

的apachectl - t爲第一個例子拋出這個錯誤; RewriteCond:糟糕的國旗分隔符 – noctorum 2012-03-27 21:18:21

+0

真的像我冠軍的冠軍......你能發佈你的確切代碼嗎? – 2012-03-27 21:21:32

+1

剛剛注意到了這個問題。阿帕奇對旗幟之間的空間感到不滿,應該是[R = 301,L] – noctorum 2012-03-27 21:31:45

相關問題