阿帕奇重写规则,如果不同的拍摄是空的 [英] Apache rewrite rule different if capture is empty

查看:148
本文介绍了阿帕奇重写规则,如果不同的拍摄是空的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有什么到目前为止是:

 <虚拟主机111.111.111.111:80>
     服务器名ex.me
     ServerAlias​​ www.ex.me     选择了FollowSymLinks +
     RewriteEngine叙述上
     重写规则^ /(。*)$ http://exemple.com/foo/$1 [R = 301,L]
< /虚拟主机>

我需要的是,如果(。*)是空的,它重写为 http://exemple.com 如果它拥有的东西,它重定向到 http://exemple.com/foo/ $ 1 - 我不知道知道该怎么做,如果空的规则。马上。现在它重定向到 http://exemple.com/foo/ 不管有什么捕获与否

感谢您的帮助。


解决方案

 重写规则^ / $ http://exemple.com/ [R = 301,L]
 重写规则^ /(+)$ http://exemple.com/foo/$1 [R = 301,L]

what I have so far is:

<VirtualHost 111.111.111.111:80>
     ServerName ex.me
     ServerAlias www.ex.me

     Options +FollowSymLinks
     RewriteEngine on
     RewriteRule ^/(.*)$  http://exemple.com/foo/$1 [R=301,L]
</VirtualHost>

what I need is if (.*) is empty, it rewrites to http://exemple.com and if it has something, it redirects to http://exemple.com/foo/$1 -- I don't know how to do the if empty rule. right now. Right now it redirects to http://exemple.com/foo/ no matter if there is something captured or not.

Thanks for your help

解决方案

 RewriteRule ^/$  http://exemple.com/ [R=301,L]
 RewriteRule ^/(.+)$  http://exemple.com/foo/$1 [R=301,L]

这篇关于阿帕奇重写规则,如果不同的拍摄是空的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆