Apache 和 PHP 上的 URL 重写/Mod 重写 .htaccess

问题描述:

我的网站上只有一个入口点

I have a single point of entry on my website

mysite.com/admin/index.php?View=List&Model=User

对数据库/应用程序的所有访问都是通过这个 index.php 文件进行的.

All access to the DB/application is through this index.php file.

我想从上面显示的内容中清除我的网址.

I would like to clean my URL from what is shown above to.

mysite.com/admin/列表/用户

这个想法是删除关键的模型"和视图".

The idea is to remove the key 'Model and 'View'.

我发现这个链接看起来非常相似.

I have found this link that looks very similar.

PHP/Apache:使用 .htaccess 重写规则

在 htaccess 文件中插入这段代码:

in htaccess file insert this code :

RewriteEngine On
RewriteRule ^admin/([^/]*)/([^/]*)$ /admin/index.php?View=$1&Model=$2 [L]

重写后的网址:

http://mysite.com/admin/List/User

这个站点对于生成重写 URL 非常有用

this site very useful for generate rewrite URL

http://www.generateit.net/mod-rewrite/