如何将文本转换使用的.htaccess为小写的网址 [英] How to convert text to lowercase URLs using .htaccess
本文介绍了如何将文本转换使用的.htaccess为小写的网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想成立301重定向在我的.htaccess文件中,这样的URL像
I want to set up 301 redirects in my .htaccess file so URLs like
http://example.com/Foo
http://example.com/Foo/Bar
http://example.com/Foo/Bar/Blah
更改
http://example.com/products/foo
http://example.com/products/foo/bar
http://example.com/products/foo/bar/blah
有一个独立的富的案件数,我可以与重写规则目标^富,但如何追加了产品的一部分?
There are a discrete number of "Foo" cases which I can target with RewriteRule ^Foo, but how to append the "products" part?
推荐答案
首先,在添加此行<虚拟主机>
部分的或的在httpd.conf文件的末尾:
First add this line in <VirtualHost>
section OR at the end of your httpd.conf file:
RewriteMap lc int:tolower
然后在.htaccess文件中的规则:
Then have these rules in .htaccess file:
RewriteEngine on
Options +FollowSymlinks -MultiViews
RewriteRule ^(Foo.*)$ /products/${lc:$1} [R=301,L]
- 在R = 301发回301到浏览器
- L代表其标记最后一条规则
这篇关于如何将文本转换使用的.htaccess为小写的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文