PHP MVC:当操作方法名包含显示时出现 404 错误


PHP MVC: 404 error when action-methodname contains show

我在当前的自定义PHP MVC项目中遇到了一个非常奇怪的问题。如果控制器方法名包含 show (fx show_album),apache 会抛出 404 页面未找到?

杜你有什么想法为什么会这样吗?

.htaccess:

#mod_rewrite start
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z]*)/?([a-zA-Z]*)?/?([a-zA-Z0-9]*)?/?$ index.php?controller=$1&action=$2&id=$3 [QSA,L]
#mod_rewrite end

顺便说一句,它适用于 url 中的正常获取请求(如 index.php?controller=profile&action=show_album&id=1

你的问题可能不是单词show,而更有可能是show_album中的下划线 - 你在htaccess中的模式与下划线不匹配。

尝试以下添加下划线的模式。

#mod_rewrite start
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z_]*)/?([a-zA-Z_]*)?/?([a-zA-Z0-9_]*)?/?$ index.php?controller=$1&action=$2&id=$3 [QSA,L]
#mod_rewrite end