url重写 - .htaccess & 301:将带有大写字母的URL重定向到相同的URL,但为小写



1(我得到了mysite.com/about-me.php。

当我在mysite.com/About-me.php中输入时,会出现404错误

我想给我的.htaccess添加一些魔法,这样mysite.com/My-PaGe.php (etc) redirects the user by 301, OR rewrites the URL (whatever is the best?) to mysite.com/my-page.php.
-301还是重写是最好的?

2( 我可能添加一个适用于所有URL的规则,还是必须手动指定所有不同的页面?

奖金3(如果有人知道如何将mysite.com/mY-paGe.php重写为mysite.com/mY-site ,将获得额外的奖金

感谢

这会执行301重定向,所有带有大写字母的url都会被重写为小写版本:

RewriteMap lc int:tolower    
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) ${lc:$1} [R=301,L]

另请参阅本文,特别是评论部分。http://www.chrisabernethy.com/force-lower-case-urls-with-mod_rewrite/

您可能需要在httpd.conf中指定此行,并在.htaccess 中指定RewriteCond/RewriteRule

RewriteMap lc int:tolower

最新更新