改变网址的改造

时间:2012-02-08 05:08:21

标签: php .htaccess cakephp mod-rewrite

如果有人点击了这样的网址:http://mydomain.com/action/login/uname/sudip/pass/md5(password

我的系统如何转换它http://mydomain.com/index.php?action=login&uname=sudip&pass=md5(password)

请为此提供重写规则。

2 个答案:

答案 0 :(得分:2)

非常简单。

RewriteEngine On

RewriteBase /your/directory/path/

RewriteRule ^(.*)action/(.*)/uname/(.*)/pass/(.*)$ index\.php?action=$2&uname=$3&pass=$42%{QUERY_STRING} [L]

答案 1 :(得分:0)

将此代码放在DOCUMENT_ROOT目录中的.htaccess文件中:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On

# your rewrite rule
RewriteRule ^(action)/([^/]*)/(uname)/([^/]*)/(pass)/([^/]*)$ index.php?$1=$2&$3=$4&$5=$6 [L,QSA,NC]