php - 301 redirect code to new folder structure URLs -


i use redirect on old site:

rewritecond %{http_host} ^(www\.)?oldsite\.com$ [nc,or] rewritecond %{http_host} ^www\. [nc] rewriterule ^oldfolder(/.*)?$ http://newsite.com/newfolder$1    [l,r=301,nc,ne]  rewritecond %{http_host} ^(www\.)?oldsite\.com$ [nc,or] rewritecond %{http_host} ^www\. [nc] rewriterule ^(.*)$ http://newsite.com/$1 [l,r=301,ne] 

this redirect code me:

  • first,to redirect www non www on new site
  • second,to redirect oldsite urls oldfolder newsite urls newfolder

the problem old urls have index.php on structure , redirection wrong. example:

oldsite.com/index.php/oldfolder/....

redirect to

newsite.com/index.php/oldfolder/....

but right redirection should to

newsite.com/index.php/newfolder/.... or newsite.com/newfolder/....

how can change redirect code make right redirections newfolder structure urls?

you can use following rule redirect oldsite/ newsite :

rewritecond %{http_host} ^(www\.)?oldsite\.com$ [nc] rewriterule ^oldfolder/(.*)$ http://newsite.com/newfolder/$1    [l,r=301,nc,ne] 

Comments

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -