2012-03-27 88 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

相关问题