[英].htaccess; Rewrite folder name in URL
I've many links like this:我有很多这样的链接:
www.example.com/my_folder/something/33
www.example.com/my_folder/anything/81
How can I rewrite my_folder
to folder123
.如何将
my_folder
重写为folder123
。
Means: If I type www.example.com/folder123/something/33
I'm getting the content of www.example.com/my_folder/something/33
but the URL remains www.example.com/folder123/something/33
.意思是:如果我输入
www.example.com/folder123/something/33
我会得到www.example.com/my_folder/something/33
的内容,但 URL 仍然是www.example.com/folder123/something/33
。
How can I do that with .htaccess
?我怎么能用
.htaccess
做到这一点?
You can do this with a simple rewrite rule as this:你可以用一个简单的重写规则来做到这一点:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+my_folder(/\S*)?\s [NC]
RewriteRule ^ /folder123%1 [R=301,L,NE]
RewriteRule ^folder123(/.*)?$ my_folder$1 [L,NC]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.