我的网站上只有一个入口点
mysite.com/admin/index.php?View=List&Model=User
所有对数据库/应用程序的访问都是通过这个index.php文件进行的。
我想从上面显示的内容中清除我的URL。
mysite.com/admin/List/User
其想法是删除键"Model"answers"View"。
我发现这个链接看起来非常相似。
PHP/Apache:使用.htaccess 重写规则
在htaccess文件中插入以下代码:
RewriteEngine On
RewriteRule ^admin/([^/]*)/([^/]*)$ /admin/index.php?View=$1&Model=$2 [L]
重写后的URL:
http://mysite.com/admin/List/User
该网站对于生成重写URL 非常有用
http://www.generateit.net/mod-rewrite/
如果您还没有一个名为.htaccess的文件,请在您的web根目录中创建一个文件:
# Turn the rewrite engine on (skip this if already done)
RewriteEngine On
# Redirect admin/List/User/ to admin/index.php?View=List&Model=User
RewriteRule ^admin/([^/.]+)/([^/.]+)/?$ admin/index.php?View=$1&Model=$2 [L]
这可能有效:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^admin/([^/]+)/([^/]+) /index.php?View=$1&Model=$2 [NC]
添加到网站根文件夹中的.htaccess。