php - Strange redirection with htaccess mod_rewrite -


in .htaccess have lines:

rewriteengine on rewritecond %{http_host} ^test.ru [nc] rewriterule ^(.*)$ http://www.test.ru/$1 [r=301,nc] rewritebase / rewriterule ^(.*)/$ index.php?string=$1 [nc,l] 

so want change test.ru www.test.ru

and give www.test.ru/my_string_value/ $_get['string']

(for example url www.test.ru/ru/pages/id/) , exploding ru/pages/888 , getting parameters (lang=ru, cat=pages, id=888).

when i'm trying check www adding part (writing test.ru must make www.test.ru) geting this:

http://www.test.ru/index.php?string=http://www.test.ru

with parameters getting ok!

and 1 interesting thing! after comenting lines

#rewriteengine on #rewritecond %{http_host} ^test.ru [nc] #rewriterule ^(.*)$ http://www.test.ru/$1 [r=301,nc] #rewritebase / #rewriterule ^(.*)/$ index.php?string=$1 [nc,l] 

getting same thing!

what wrong.

you have things in wrong order cached. browser cache 301 redirects. clear browser cache or try in browser. use 302 while testing. change 301 when working. , should use l flag on redirects well.

rewriteengine on rewritebase / rewritecond %{http_host} ^test\.ru [nc] rewriterule ^(.*)$ http://www.test.ru/$1 [r=302,nc,l] rewriterule ^(.*)/?$ index.php?string=$1 [nc,l] 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -