Lui*_*cia 1 php apache redirect magento
出于某种原因,一个magento网址在我的网站上运行不正常.请参见此处: 完整性约束违规:1052订单子句中的列"位置"不明确
所以,我决定我可以为这个失败的url做一个重定向:我试过apache但是它不起作用看到这里: Apache简单重定向从一个页面到另一个页面
他们建议用php做
有人可以解释我如何用PHP做到这一点?
就像是
if url = 'myfaliingurl' then
redirect to new url
Run Code Online (Sandbox Code Playgroud)
而已
这是我在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
Run Code Online (Sandbox Code Playgroud)
更新1:
它不起作用,我把它放在index.php的最后.
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');
}
Run Code Online (Sandbox Code Playgroud)
如果您只想使用PHP,则可以使用 header()
header("Location: http://www.example.com/"); /* Redirect browser */
Run Code Online (Sandbox Code Playgroud)
所以:
if (/*whatever you're checking*/){
header("Location: http://www.example.com/"); /* Redirect browser */
exit();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1734 次 |
| 最近记录: |