php – MVC htaccess重写

你好,我在我自己的mvc中的htaccess配置有问题. IDK我做错了什么?我有这个消息500:

Internal Server Error

The server encountered an internal error or misconfiguration and was
unable to complete your request.

Please contact the server administrator, admin@localhost and inform
them of the time the error occurred, and anything you might have done
that may have caused the error.

More information about this error may be available in the server error
log.

我想让url重写为索引.
尝试做这样的事情

www.example.com/index.php/controller/method/param

www.example.com/index.php?url=controler

我的.htaccess看起来像这样:

RewriteEngine On

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

RewriteRule ^(.+) index.php?url=$l [QSA,L]

我做错了什么?我读了http://httpd.apache.org/docs/current/rewrite/flags.html,怎么解释.

解决方法:

如果您的.htaccess隐藏文件位于主根目录中,请检查这些配置指令:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^index\.php/([a-zA-Z0-9_-]+)/method/param$/index.php?url=$1 [QSA,L]

它会将www.example.com/index.php/$var/method/param重写为www.example.com/index.php?url=$var但请确保您的.htaccess文件位于主根目录中.

上一篇:正则表达式 – RewriteRule ^(.*)/ $?path = $1 [QSA,L]在我的.htaccess中意味着什么?


下一篇:CakePHP在一个使用nginx的子目录中(重写规则?)