4

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.

1
  • I think you need to describe what you need with a term other than "GET methods" seeing as GET method means something else: en.wikipedia.org/wiki/… Commented Apr 2, 2010 at 23:40

3 Answers 3

10

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?

Sign up to request clarification or add additional context in comments.

Comments

6

In Perl compatible RegExs a $ is an anchor, which denotes "the end". So remove the $ from the middle of your pattern, after ^adm/(.*):

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

3 Comments

+1, but escaping the forward slashes in the context above is not necessary (also the dollar sign can be left out entirely).
I've edited the post again... need some help on the other bit
@ChristopheD - Cool! Thanks; I'll remove the "escape the slashes" part.
0

Instead of writing complex regular expressions in the .htaccess, I would just use a simple

RewriteCond $1 !^adm\.php
RewriteRule ^adm/(.*)$ adm.php/$1 [L]

and work with $_SERVER['PHP_SELF'] inside adm.php so you can handle any kind of complex URL which starts with adm without changing the .htaccess.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.