忽略最后的目录,如果它是第二个目录的mod_rewrite [英] ignore last directory if it is the second directory mod_rewrite
本文介绍了忽略最后的目录,如果它是第二个目录的mod_rewrite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图建立一个mod_rewrite的,将做以下
www.mysite.com/dir/ignoreMe
将映射到
www.mysite.com/dir
然而,在浏览器的URL仍将显示为
www.mysite.com/dir/ignoreMe
如果输入的网址是根本
www.mysite.com/dir
重写不应该做任何事情。
这样我可以使用的最后一个/第二个目录,就好像它是一个GET查询字符串
解决方案
重写规则^([^ /] *)/([^ /] +)/ $ 1
I am attempting to setup a mod_rewrite that will do the following
www.mysite.com/dir/ignoreMe
will map to
www.mysite.com/dir
however in the browser the url will still appear to be
www.mysite.com/dir/ignoreMe
if the url entered is simply
www.mysite.com/dir
the rewrite shouldn't do anything.
This way I can use the last/ second directory as if it was a GET query string
解决方案
RewriteRule ^([^/]*)/([^/]+)$ /$1
这篇关于忽略最后的目录,如果它是第二个目录的mod_rewrite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文