Apache 将对特定子目录的所有请求重写为主页

Apache 将对特定子目录的所有请求重写为主页,apache,mod-rewrite,Apache,Mod Rewrite,我想将所有向特定子目录发送请求的用户推回到主页。例如: http://test.example.com/apps/ http://test.example.com/apps/sd1 http://test.example.com/apps/fjwoiejf/jiejn 应全部重写为: http://test.example.com web服务器是Apache。请在test.example.com根目录下的htaccess文件中确认: RewriteEngine on RewriteRule

我想将所有向特定子目录发送请求的用户推回到主页。例如:

http://test.example.com/apps/
http://test.example.com/apps/sd1
http://test.example.com/apps/fjwoiejf/jiejn
应全部重写为:

http://test.example.com

web服务器是Apache。

请在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]

对于第一个示例,apachectl-t抛出此错误;重写第二条:坏国旗分隔符真的像我这边的冠军一样工作。。。你能公布你的确切密码吗?我刚注意到这个问题。Apache对标志之间的空格不满意,应该是[R=301,L]很好的捕获,出于某种原因,我想我现在在更新票证时错误地键入了这些标志