简体   繁体   English

htaccess重定向为mvc模式网站?

[英]htaccess redirect for a mvc pattern website?

RewriteEngine On

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

RewriteRule ^(.*)$ index.php?url=$1

Above is the .htaccess file content that is used for frontend portion of a mvc pattern web site. 以上是.htaccess文件内容,用于mvc模式网站的前端部分。 My requirement: changing 我的要求:改变

localhost/ecommerce/admin.php?url=site/login

into

localhost/ecommerce/admin/site/login

Here, 'site' represents the class name & 'login' represents the method name. 这里,'site'代表类名,'login'代表方法名。 'admin' is supposed to indicate that the url represents backend portion of the web site. 'admin'应该表示url代表网站的后端部分。

Update: i'm not using any framework. 更新:我没有使用任何框架。 anyway, does it matter? 无论如何,这有关系吗?

You can use a RewriteRule : 你可以使用RewriteRule

RewriteRule ^([a-zA-Z_0-9]+)\/([a-zA-Z0-9_]+)\/([a-zA-Z0-9_]+)\/?$ $1.php?url=$2/$3 [L,QSA,PT]

Here is a good post about RewriteRule : http://kb.mediatemple.net/questions/85/Using+.htaccess+rewrite+rules#gs 这是一篇关于RewriteRule的好文章: http//kb.mediatemple.net/questions/85/Using+.htaccess+rewrite+rules#gs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM