views:

426

answers:

2

/foo/.htaccess does an internal redirect

RewriteRule ^(.*)$ /bar/?%{ENV:UNIQUE_ID}

/bar/.htaccess needs to recognise that the request was NOT internal, the issue is that I cannot figure out how to make the comparision work

RewriteCond %{ENV:UNIQUE_ID} !%{QUERY_STRING}

even a

RewriteCond %{QUERY_STRING} %{QUERY_STRING}

won't match, I suppose there is a syntax issue in the right-hand of the expression, escaping % doesn't help.

I tested that the above both variable have the same value on an internal redirect as

RewriteRule ^(.*)$ /test/%{QUERY_STRING}/%{ENV:UNIQUE_ID}

would show it.

The server is Apache/2.2.3

Thanks, Laurian

+2  A: 

Sadly you cannot compare two variables directly with mod_rewrite. (Or at least I don’t know how to do this either.)

But there is a workaround for this:

RewriteCond %{ENV:UNIQUE_ID}:%{QUERY_STRING} !^(.+):\1$

I chose the : as separator but you can use any other separator if you want to. And if you can specify the structure of UNIQUE_ID values, you should do that.

Gumbo
A: 

well. if the referrer wasn't the same domain you are on, such as the first time a person visits but didn't use a link within your own website you could check the HTTP_REFERRER. Same technique is used to prevent hotlinking to images.

kayakbabe