回答編集履歴
2
ミスがあったため修正。
answer
CHANGED
@@ -40,7 +40,35 @@
|
|
40
40
|
functions.php
|
41
41
|
```PHP
|
42
42
|
function load_script() {
|
43
|
-
if ( !is_admin()
|
43
|
+
if ( !( is_admin()
|
44
|
+
|| is_blog_admin()
|
45
|
+
|| is_user_admin()
|
46
|
+
|| is_network_admin()
|
47
|
+
|| is_404()
|
48
|
+
|| is_preview()
|
49
|
+
) && (
|
50
|
+
is_home()
|
51
|
+
|| is_front_page()
|
52
|
+
|| is_archive()
|
53
|
+
|| is_category()
|
54
|
+
|| is_tag()
|
55
|
+
|| is_tax()
|
56
|
+
|| is_author()
|
57
|
+
|| is_date()
|
58
|
+
|| is_year()
|
59
|
+
|| is_month()
|
60
|
+
|| is_day()
|
61
|
+
|| is_time()
|
62
|
+
|| is_post_type_archive()
|
63
|
+
|| is_search()
|
64
|
+
|| is_singular()
|
65
|
+
|| is_single()
|
66
|
+
|| is_page()
|
67
|
+
|| is_attachment()
|
68
|
+
|| is_page_template()
|
69
|
+
|| is_paged()
|
70
|
+
)
|
71
|
+
) {
|
44
72
|
header ( 'HTTP/1.1 301 Moved Permanently' );
|
45
73
|
header ( 'Location: '.'http://リダイレクト先URL'.$_SERVER['REQUEST_URI'] );
|
46
74
|
exit();
|
1
補足の追加。
answer
CHANGED
@@ -29,4 +29,22 @@
|
|
29
29
|
RewriteCond %{REQUEST_URI} ^/wp-trackback.php
|
30
30
|
RewriteCond %{REQUEST_URI} ^/xmlrpc.php
|
31
31
|
RewriteRule ^(.*)$ リダイレクト先URL/$1 [R=301,L]
|
32
|
+
```
|
33
|
+
|
34
|
+
---
|
35
|
+
|
36
|
+
**追記:**
|
37
|
+
|
38
|
+
WordPress 側でリダイレクトしてしまうとか。
|
39
|
+
|
40
|
+
functions.php
|
41
|
+
```PHP
|
42
|
+
function load_script() {
|
43
|
+
if ( !is_admin() ) {
|
44
|
+
header ( 'HTTP/1.1 301 Moved Permanently' );
|
45
|
+
header ( 'Location: '.'http://リダイレクト先URL'.$_SERVER['REQUEST_URI'] );
|
46
|
+
exit();
|
47
|
+
}
|
48
|
+
}
|
49
|
+
add_action( 'init', 'load_script' );
|
32
50
|
```
|