1

何らかの理由で、1 つの magento URL が私の Web サイトで正常に機能していません。こちらを参照してください: 整合性制約違反: 1052 列 'position' in order 句があいまいです

だから、私はこの失敗した URL のリダイレクトを行うことができると決めました: Apache で試しましたが、うまくいきません ここを参照してください: Apache simple redirect from one page to a second one

彼らはphpでそれを行うことを提案しました

誰かがphpでこれを行う方法を説明してもらえますか?

何かのようなもの

if url = 'myfaliingurl' then
  redirect to new url

それでおしまい

これは私が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

更新 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');
}
4

6 に答える 6

5

PHPを使いたいだけなら、header()

header("Location: http://www.example.com/"); /* Redirect browser */

それで:

if (/*whatever you're checking*/){
    header("Location: http://www.example.com/"); /* Redirect browser */
    exit();
}
于 2012-11-20T08:53:39.163 に答える
2

このコードを使用すると、

 <?php
  if($url == 'myfaliingurl')
  {
          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');
  }
  else{
          header('location:otherposition');
  }
  ?>
于 2012-11-20T08:55:42.523 に答える
0
if(url == 'myfaliingurl')
   redirect('newUrl');


function redirect($url)
{
   header("Location: $url");
}
于 2012-11-20T09:03:06.590 に答える
0

必要なものは次のように書かれています: phpheader()関数の前に何も出力しないことを忘れないでください。

$url = "myfailingurl";
$newurl = "http://www.mynewurl.com/blabla";

if ($url == "myfailingurl"){
     header("Location: $newurl"); die();
}

header()関数の詳細については、 http: //php.net/manual/en/function.header.phpをご覧ください。

于 2012-11-20T08:58:55.987 に答える
0

PHP では、header()関数を使用してリクエストをリダイレクトできます。

header('Location: http://www.example.com/');

http://php.net/manual/en/function.header.php

于 2012-11-20T08:53:50.197 に答える
0

PHP を使用すると、次のようになります。

<?php
header('Location: http://www.example.com/');
// if you get a header error, which is really frequent, try with javascript like this:
echo '<script type="text/javascript">window.location ="http://www.example.com";</script>';
?>
于 2012-11-20T09:01:29.833 に答える