For some reason one magento url is not working fine on my website. see here: Integrity constraint violation: 1052 Column 'position' in order clause is ambiguous
So, I decided that I could do a redirect for this failing url: I tried with apache but it doesnt work see here: Apache simple redirect from one page to a second one
They suggested to do it with php
can someone pls explain me how to do this with php?
something like
if url = 'myfaliingurl' then
redirect to new url
thats it
this is what I tried in apache
Redirect 301 http://www.theprinterdepo.com/catalogsearch/result/index/?cat=100&q=1022&x=0&y=0 http://www.theprinterdepo.com/catalogsearch/advanced/result/?name=1022&sku=&price%5Bfrom%5D=&price%5Bto%5D=&free_shipping=&category=100
Update 1:
Its not working, I put this on index.php at the end.
if($url == 'http://www.theprinterdepo.com/catalogsearch/result/index/?cat=100&q=1022&x=0&y=0')
{
header('location:http://www.theprinterdepo.com/catalogsearch/result/index/?cat=100&q=1022&x=0&y=0 http://www.theprinterdepo.com/catalogsearch/advanced/result/?name=1022&sku=&price%5Bfrom%5D=&price%5Bto%5D=&free_shipping=&category=100');
exit();
}
else
{
Mage::run('printerdepo','website');
}