MVC htaccess rewrite


MVC htaccess rewrite

你好,我有我的htaccess配置在我自己的mvc问题。我不知道我做错了什么?我总是收到这样的消息500:

内部服务器错误

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

请联系服务器管理员admin@localhost并通知错误发生的时间,以及您可能做过的任何事情这可能导致错误。

有关此错误的更多信息可以在服务器错误中获得日志。

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

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

www.example.com/index.php ? url =控制器

我的。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并做了解释
<IfModule mod_rewrite.c>    
    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !-f
    RewriteCond %{REQUEST_URI} !-d
    RewriteCond %{REQUEST_URI} !-l
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

这个应该能行

http://www.mysite.com/stats

=>

http://www.mysite.com/index.php?url=stats

试试这个:

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?url=$1 [L]
</IfModule>

最后一行出现错误:

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

应该是:

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

换句话说,将$l(字母el)更改为$1(数字1)。此外,您可能希望括号后的$关闭行。

请检查这些配置指令,如果您的。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/paramwww.example.com/index.php?url=$var但是要确保你的