是否可以删除一个";文件夹";在URL的末尾使用.htaccess文件?
所以我有一堆URL是否可以删除一个";文件夹";在URL的末尾使用.htaccess文件?,.htaccess,mod-rewrite,url-rewriting,yii,.htaccess,Mod Rewrite,Url Rewriting,Yii,所以我有一堆URL http://foo.com/people/smith/john/1 http://foo.com/people/cartman/eric/2 http://foo.com/people/simpson/bart/3 我想这样更改URL http://foo.com/people/smith/john/ http://foo.com/people/cartman/eric/ http://foo.com/people/simpson/bart/ 因此,基本上,我认为我需要
http://foo.com/people/smith/john/1
http://foo.com/people/cartman/eric/2
http://foo.com/people/simpson/bart/3
我想这样更改URL
http://foo.com/people/smith/john/
http://foo.com/people/cartman/eric/
http://foo.com/people/simpson/bart/
因此,基本上,我认为我需要编写一个条件来查找文件夹“people”,并从URL中删除第三个目录。我的.htaccess可以这样做吗 在文档根目录的htaccess文件中,尝试:
RewriteEngine On
RewriteRule ^people/([^/]+)/([^/]+)/.+ /people/$1/$2 [L,R=301]
这会将浏览器(更改地址栏中的URL)从
,R=301