【问题标题】:rewiterule for changing url [closed]用于更改网址的重写规则 [关闭]
【发布时间】:2012-02-08 15:07:22
【问题描述】:

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

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

请给出一个重写规则。

【问题讨论】:

  • 为什么url中有函数?
  • 我强烈建议不要在 url 中传递密码(甚至不经过哈希处理!)

标签: php .htaccess cakephp mod-rewrite


【解决方案1】:

很简单。

RewriteEngine On

RewriteBase /your/directory/path/

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

【讨论】:

  • 我觉得应该是这样的 RewriteRule ^action/(.*)/uname/(.*)/pass/(.*)$ index\.php?action=$2&uname=$3&pass =$42%{QUERY_STRING} [L]
【解决方案2】:

将此代码放入 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]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-14
    • 1970-01-01
    相关资源
    最近更新 更多