mod_rewrite gives me 404

五迷三道 提交于 2019-12-12 18:15:00

问题


I wanna rewrite links like index.php?page=entry&id=15&action=edit to entry/15/edit.
This is how my .htaccess looks like now:

# Turn the Rewrite engine on
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

# Rewrite rules
RewriteRule ^([^/]*)(/([^/]*)/?)([^/]*)?$ index.php?page=$1&id=$2&action=$3 [QSA,L]

Gives me 404.

What's the problem?


回答1:


Too many parentheses. You might have a Lisp infection.

Try:

RewriteRule ^([^/]*)/([^/]*)/?([^/]*)?$ index.php?page=$1&id=$2&action=$3 [QSA,L]



回答2:


There's a really good one page mod_rewrite cheat sheet here: https://www.cheatography.com/davechild/cheat-sheets/mod-rewrite/



来源:https://stackoverflow.com/questions/538097/mod-rewrite-gives-me-404

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!