Apache 和 PHP 上的 URL 重写/Mod 重写 .htaccess [英] URL Rewrite/Mod Rewrite .htaccess on Apache and PHP

查看:33
本文介绍了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/

这篇关于Apache 和 PHP 上的 URL 重写/Mod 重写 .htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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