htaccess无法正常工作--500内部服务器错误

时间:2016-01-16 15:41:45

标签: php apache .htaccess mod-rewrite

.htaccess无法正常工作,apache配置,我安装apache,php7,mysql AS seprate,我启用mod_rewrite,但是在htaccess中我输入它给我500内部服务器错误

<IfModule mod_rewrite.c>

# Turn on Rewrite Engine
RewriteEngine on

# Rewrite rule

#RewriteRule ^detail detail.php [NC,L]

# NC makes the rule non case sensitive
# L  makes the last rule that specific condition will match

# Rewrite For detail.php?id=1

RewriteRule ^detail/([0-9a-zA-Z]+) detail.php?id=$1 [NC,L]


# Rewrite For detail.php?id=1&title=title

RewriteRule ^detail/([0-9]+)/([0-9a-zA-Z]+) detail.php?id=$1&title=$2 [NC,L]


<IfModule>
  

内部服务器错误

     

服务器遇到内部错误或配置错误,无法完成您的请求。

     

请通过admin@example.com与服务器管理员联系,告知他们此错误发生的时间以及您在此错误发生之前执行的操作。

     

服务器错误日志中可能提供了有关此错误的更多信息。

1 个答案:

答案 0 :(得分:1)

结尾<Ifmodule>应为</Ifmodule>。就像那是打开第二个街区。

<IfModule mod_rewrite.c>
# Turn on Rewrite Engine
RewriteEngine on
# Rewrite rule
#RewriteRule ^detail detail.php [NC,L]
# NC makes the rule non case sensitive
# L  makes the last rule that specific condition will match
# Rewrite For detail.php?id=1
RewriteRule ^detail/([0-9a-zA-Z]+) detail.php?id=$1 [NC,L]
# Rewrite For detail.php?id=1&title=title
RewriteRule ^detail/([0-9]+)/([0-9a-zA-Z]+) detail.php?id=$1&title=$2 [NC,L]
</IfModule>