MVC htaccess 重写 [英] MVC htaccess rewrite

查看:23
本文介绍了MVC htaccess 重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我在自己的 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.

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

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/method/param 重写为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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆