我有一个想法,这是杀死我,因为我不是很好的htaccess。
我有http://(www./non-www.)example.com/dir/page/file的网址。但我想将其重定向到目录root/release/.../dir/page/file
所以
root/.htaccess
root/release/1.0/...
root/release/1.5/...
root/release/2.0/...
root/admin/1.0/...
root/admin/1.5/...
root/admin/2.0/...
etc如果他们浏览example.com/admin,您可以转到example.com/admin/2.0。但我认为棘手的一点是,我不希望example.com/release/version或example.com/admin/version被看到。
或者我可以只让这两个版本托管release/stable和release/beta。
我希望这对某些人有意义,谢谢
发布于 2013-02-24 20:51:28
听起来最简单的事情就是制作一个像example.com/admin这样的元重定向到example.com/admin/2.0的页面,然后你只需要做一个mod重写就可以返回到通用的url。当您增加版本时,只需更改元刷新,因为您的.htaccess修改重写将具有与您的版本编号系统匹配的reg-ex。
示例:
首先,对于example.com/admin文件,在头文件中实现元刷新:
<meta http-equiv="refresh" content="0;URL='example.com/admin/2.0'">现在,从2.0 (或任何版本)重写回您想要的位置:
#first, we need to define the request, in this case, admin/any number
RewriteCond %{THE_REQUEST} /admin/([0-9]*)
# now we need to make it look like it's just the plain admin page
RewriteRule ^$ /admin [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^admin /admin/([0-9]*) [L]您需要修复我的reg-ex匹配,使其成为2 "point“0
https://stackoverflow.com/questions/15051754
复制相似问题