MVC htaccess的重写 [英] MVC htaccess rewrite
问题描述
您好我有问题,在我自己的MVC我htaccess的配置。 IDK我做什么了?所有的时间我有这个消息500:
Hello i have problem with my htaccess configuration in my own mvc. IDK what i do wrong? All time i have this message 500:
内部服务器错误
服务器遇到一个内部错误或配置错误, 无法完成您的请求。
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重写索引。 尝试做财产以后像这样
I want to make url rewrite to index. Try to do somthing like this
www.example.com/index.php/controller/method/param
www.example.com/index.php/controller/method/param
www.example.com/index.php?url=controler
www.example.com/index.php?url=controler
我的.htaccess是这样的:
My .htaccess look like this:
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的并在那里做如何解释。
What i do wrong ?? I read http://httpd.apache.org/docs/current/rewrite/flags.html and do how is there explained.
推荐答案
如果请检查这些配置指令您的的.htaccess 的隐藏文件中的主要根源:
Please check these configuration directives if your .htaccess hidden file is in the main root:
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 /方法/参数的成的 www.example.com/index.php? URL = $ VAR 的,但请确保您的的.htaccess 的文件是主要根源。
It will rewrite www.example.com/index.php/$var/method/param into www.example.com/index.php?url=$var but make sure that your .htaccess file is in the main root.
这篇关于MVC htaccess的重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!