当我尝试使301redirect时,我得到一个内部错误代码500:
Rewriterule ^categoy/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)? product_detail.php?category=$1&subcategory=$2&product=$4 [QSA,NC]
RewriteMap fiel:
RewriteMap lc int:tolower RewriteCond %{REQUEST_URI} [AZ] RewriteRule (.*) ${lc:$1} [R=301,L]
任何build议,为什么我得到这个错误?
谢谢
当你从Apache获得一个500错误时,Apache会记下你为什么会在你的error_log给你那个错误,无论它在哪里configuration。 请参阅该日志中的错误消息,以了解您做错了什么。
.htaccess文件中不允许使用RewriteMap指令。 它应该写在Apache的configuration文件httpd.conf中。
好吧…让我们直接得到一些东西。
Rewriterule ^categoy/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)? product_detail.php?category=$1&subcategory=$2&product=$4 [QSA,NC]
这里有很多冗余的东西在这里例如NC不区分大小写匹配无论如何..我格式化你的代码有点:
RewriteMap lc int:tolower RewriteCond %{REQUEST_URI} [AZ] RewriteRule (.*) ${lc:$1} [R=301,L]
你现在在谈什么规则? 从你的头衔(301)我想第二个。 你的rewritecondition看起来很奇怪。 但是,与重写规则相关的错误500的最常见原因是缺less权限。 确保在服务器configuration中执行AllowOverride All或者在那里移动你的规则(这比htaccess文件提供更多的性能)