teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

現状を詳しく追記

2021/03/04 03:12

投稿

fkshin
fkshin

スコア12

title CHANGED
@@ -1,1 +1,1 @@
1
- phpでheader を使った301リダイレクトが一部効かない原因
1
+ phpでheader を使った301リダイレクトが一部効かず画面が真っ白に
body CHANGED
@@ -2,6 +2,9 @@
2
2
  **「私より以前に作業したものに関してはリダイレクトがきくけど私が作業したものは効かない」**
3
3
  という現象が起こっています。
4
4
 
5
+ また、自分があとから記載したものに関しては真っ白の画面になってしまって、301もきいてるのかきいてないのかわからない状態になってしまいます。
6
+ どうしたらいいかお手上げでして、開発ツールで確認してみたところ、index.phpは読み込むものの最初の下記のheader部分から下が読み込まれていない感じになっています。
7
+
5
8
  もちろん記載漏れや書き間違いなどの可能性は精査した上です。
6
9
 
7
10
  ```php

1

書き足しを追加

2021/03/04 03:12

投稿

fkshin
fkshin

スコア12

title CHANGED
File without changes
body CHANGED
@@ -34,8 +34,37 @@
34
34
  ?>
35
35
  ```
36
36
 
37
+
37
38
  このexit();から下に同じようにコピペしてリダイレクトを足していったのですが、これに追記するとリダイレクトが効きません。
38
39
 
40
+ ```php
41
+ <?php
42
+ if($_SERVER['PHP_SELF'] == "/2016/jpn/product/acGen/index.php"){
43
+ header("Location: https://hogehoge.com/products/acgen/",true,301);
44
+ exit();
45
+ }else if($_SERVER['PHP_SELF'] == "/2016/jpn/product/cellec/index.php"){
46
+ header("Location: https://hogehoge.com/products/cellecv/",true,301);
47
+ exit();
48
+ }else if($_SERVER['PHP_SELF'] == "/2016/jpn/product/lipocel/index.php"){
49
+ header("Location: https://hogehoge.com/products/lipocel2/",true,301);
50
+ exit();
51
+ }else if($_SERVER['PHP_SELF'] == "/2016/jpn/product/tribeam/index.php"){
52
+ header("Location: https://hogehoge.com/products/tribeampremium/",true,301);
53
+ exit();
54
+ }else if($_SERVER['PHP_SELF'] == "/2016/jpn/company/event/workshop/index.php"){
55
+ header("Location: https://hogehoge.com/event/",true,301);
56
+ exit();
57
+ }else if($_SERVER['PHP_SELF'] == "/2016/jpn/product/edgeone/index.php"){
58
+ header("Location: https://hogehoge.com/products/edgeone/",true,301);
59
+ exit();
60
+ }
61
+ //smoothcool is /2016/jpn/product/smoothcool/index.php inline code
62
+ require_once ($_SERVER["DOCUMENT_ROOT"]. "/include/Define.include.php");
63
+ require_once (__ROOT_DIR__. "include/Link.include.php");
64
+
65
+ ?>
66
+ ```
67
+
39
68
  この場合考えられる可能性はなんだと思うか、知恵を貸していただけたら幸いです。
40
69
  .htaccessだろうかとも考えているのですが…
41
70