.htaccess中删除多个子或隐藏子目录(S) [英] Htaccess remove multiple substring or hide subdirectory(s)

查看:166
本文介绍了.htaccess中删除多个子或隐藏子目录(S)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  http://www.example.com/blog/demo/first-post
http://www.example.com/blog/test/second-post
 

我想重写上述网址与htaccess的下面,

  http://www.example.com/first-post
http://www.example.com/second-post
 

简单地说,

如果请求的URI包含子'博客',应该删除'博客',下一个项目,concatinate遗体与firstpart

感谢

解决方案

 重写规则^ /博客/.*?/(.*)$ $ 1 [NC,L]
 

http://www.example.com/blog/demo/first-post
http://www.example.com/blog/test/second-post

I would like to rewrite the above url to following with htaccess,

http://www.example.com/first-post
http://www.example.com/second-post

Simply,

If requested uri contains substring 'blog' it should remove 'blog' and the next item and concatinate the remains with firstpart

Thanks

解决方案

RewriteRule ^/blog/.*?/(.*)$  $1  [NC,L]

这篇关于.htaccess中删除多个子或隐藏子目录(S)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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