我目前正面临着重写规则的挑战,我网站上的apache错误日志将我的重写规则的某些部分记录为错误,报告文件不存在。示例`[Thu Jan 15 17:27:48 2015] [错误] [client ***** ip ****]文件不存在:/ home / nst1 / public_html / events,referer:https://www.example.com/events/23924/Understanding-Core-HR-Processes-
重写规则:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^/]+)/?$ $1.php [NC,L]
RewriteRule ^events/([0-9]+)/([^/]+)/?$ event-detail.php?detail=$1 [NC,L]`
有没有人知道如何编写一个不会产生此错误的重写规则?
答案 0 :(得分:1)
尝试更改规则的顺序:
RewriteEngine on
RewriteRule ^events/([0-9]+)/([^/]+)/?$ event-detail.php?detail=$1 [NC,L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/?$ $1.php [L]