2012-02-08 55 views
1

如果有人打這樣的網址:http://mydomain.com/action/login/uname/sudip/pass/md5(passwordrewiterule改變URL

怎麼能在我的系統將其轉換http://mydomain.com/index.php?action=login&uname=sudip&pass=md5(password)

請給出一個重寫規則。

+0

爲什麼有url中的功能呢? – 2012-02-08 05:17:21

+0

我強烈建議不要在URL中傳遞密碼(甚至沒有散列!) – mark 2012-02-08 12:48:35

回答

2

非常簡單。

RewriteEngine On 

RewriteBase /your/directory/path/ 

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

我認爲這應該是這樣的RewriteRule^action /(.*)/ uname /(.*)/pass/(.*)$ index \ .php?action = $ 2&uname = $ 3&pass = $ 42%{QUERY_STRING} [L] – 2012-02-08 06:27:11

0

將這個代碼在.htaccess文件中DOCUMENT_ROOT目錄:

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]