1

I've these lines in .htaccess file:

RewriteCond %{HTTP_COOKIE} ^.*ddl=([^;]+);\sddc=([^;]+).*$ [NC]
RewriteCond %1 =%2
RewriteRule .* index.php?ddc=%2&ddl=%1 [L]

%{HTTP_COOKIE} conaitns ddl=123456; ddc=123456.

When I go through a URL it doesn't work as expected above. But if I change second line to RewriteCond %1 !=%2 it goes to index.php. In that file I did a var_dump($_GET) and output was this:

array(2) { ["ddc"]=> string(6) "123456" ["ddl"]=> string(6) "123456" }

My question is that, so why RewriteCond %1 =%2 doesn't work as it should!

revo
  • 43,830
  • 14
  • 67
  • 109

1 Answers1

3

You can't use %1, %2 etc in RewriteCond. Try this code for back referencing:

RewriteCond %{HTTP_COOKIE} ^.*ddl=([^;]+);\sddc=\1.*$ [NC]
RewriteRule ^ index.php?ddc=%2&ddl=%1 [L]
anubhava
  • 664,788
  • 59
  • 469
  • 547