强制小写的.htaccess [英] Force lowercase .htaccess
本文介绍了强制小写的.htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图做
RewriteEngine叙述上
RewriteMap指令LC INT:TOLOWER
的RewriteCond%{REQUEST_URI} [A-Z]
(。*)重写规则$ {LC:$ 1} [R = 301,L]
不过,我收到500内部错误。不知道什么是错的。
错误:
/home/public_html/.htaccess:RewriteMap指令此处不允许
[周一7月18日10点33分06秒2011] [警惕] [客户端* *。*。*] /home/public_html/.htaccess:RewriteMap指令这里不允许
解决方案
如果你使用PHP,你可以在你的index.php的开始把这个
$ URL = $ _ SERVER ['REQUEST_URI'];
$模式='/([A-Z] +)/';
如果(preg_match($模式,$网址)){
$ new_url =用strtolower($网址);
头(HTTP / 1.1 301永久移动);
头('位置:'$ new_url。);
出口;
}
//你的code在这里
I tried to do
RewriteEngine On
RewriteMap lc int:tolower
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) ${lc:$1} [R=301,L]
But, I receive a 500 internal error. Not sure what's wrong.
Error:
/home/public_html/.htaccess: RewriteMap not allowed here
[Mon Jul 18 10:33:06 2011] [alert] [client *.*.*.*] /home/public_html/.htaccess: RewriteMap not allowed here
解决方案
If your using PHP you could put this in the beginning of your index.php
$url = $_SERVER['REQUEST_URI'];
$pattern = '/([A-Z]+)/';
if(preg_match($pattern, $url)) {
$new_url = strtolower($url);
Header( 'HTTP/1.1 301 Moved Permanently' );
Header( 'Location: ' . $new_url );
exit;
}
// your code here
这篇关于强制小写的.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文