Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
325 views
in Technique[技术] by (71.8m points)

php - Getting two variables in the URL with htaccess

What way it is to be to get two GET methods in the URL by htaccess?

RewriteRule ^adm/(.*)$ adm.php?mode=$1

I've used that for the example URL:

http://www.domain.com/adm/thismode

Now I want to get two methods like:

http://www.domain.com/adm/thismode/othermode

I've tried this:

RewriteRule ^adm/(.*)$/(.*)$ adm.php?mode=$1&othermode=$2

But doesn't seem to work... how do I get it to do that?

EDIT:

$mode1 = $_GET['mode'];

$mode2 = $_GET['othermode'];

Like this...

EDIT AGAIN:

http://www.domain.com/adm/generated/pass/6z9c4q9k8p

Right... this is the URL it has to do

And in the PHP it has this:

if($mode == "generated")

I want the PHP to see if the mode is set in the URL and the generated password is the other GET

I put the htaccess as this way:

RewriteRule ^adm/(.*)/(.*)$ adm.php?mode=$1&generated=$2

The PHP will also grab the generated password in the URL and display it on the page.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

what's the problem you're having now Seems like Richard got you what you needed?

Using your example URL:

http://www.domain.com/adm/generated/pass/6z9c4q9k8p

and the following in your .htaccess

RewriteRule ^adm/(.*)/(.*)/(.*)$ adm.php?mode=$1&generated=$2&pass=$3

then you can do:

$mode1 = $_GET['mode'];
$generated = $_GET['generated'];
$pass = $_GET['pass'];
if ( $mode1 == 'generated' && $generated == 'pass' ) 
    echo $pass;

or was that not your question?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...