質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

phpMyAdmin

phpMyAdminはオープンソースで、PHPで書かれたウェブベースのMySQL管理ツールのことです。

WordPress

WordPressは、PHPで開発されているオープンソースのブログソフトウェアです。データベース管理システムにはMySQLを用いています。フリーのブログソフトウェアの中では最も人気が高く、PHPとHTMLを使って簡単にテンプレートをカスタマイズすることができます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

データベース

データベースとは、データの集合体を指します。また、そのデータの集合体の共用を可能にするシステムの意味を含めます

Q&A

2回答

2017閲覧

WPの管理画面にログインできない

qpooooh

総合スコア11

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

phpMyAdmin

phpMyAdminはオープンソースで、PHPで書かれたウェブベースのMySQL管理ツールのことです。

WordPress

WordPressは、PHPで開発されているオープンソースのブログソフトウェアです。データベース管理システムにはMySQLを用いています。フリーのブログソフトウェアの中では最も人気が高く、PHPとHTMLを使って簡単にテンプレートをカスタマイズすることができます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

データベース

データベースとは、データの集合体を指します。また、そのデータの集合体の共用を可能にするシステムの意味を含めます

0グッド

0クリップ

投稿2019/12/18 03:41

編集2022/01/12 10:55

サーバーサイドに詳しくないフロントエンドです。
WPの管理画面にログインすると、サイトのトップページへリダイレクトされてしまい困っています。
ログイン後、正しく管理画面へリダイレクトされるように修正したいです。

【環境】
wordpress5.2.4

【経緯】
・ステージング環境から本番環境へwordpressのデータを移行
・ステージング環境と本番環境で、使用するDB及び接頭辞が違う
・SQLファイルのテーブル名、サイトURL、インストールURL投稿URLを本番のものへ変更しインポート
・wp-config.phpを本番環境のDBへ書き換えてアップロード
・.htaccessを本番用に書き換えてアップロード(ステージング環境のURLを本番URLに変更する程度)

【現状】
・サイトは正しく表示されている(CSS、JS、画像ファイル、固定ページ、投稿ページなど)
・ログイン画面は正しく表示される
・ログイン失敗時は通常のエラー画面となる
・ログイン成功時はサイトのTOPページへリダイレクトされる
・TOPページへのリダイレクト後、再びログイン画面へ移動するとログインを要求される

以上となります。
不足している情報などございましたら、ご指摘いただけますと幸いです。
ご教示のほど、よろしくお願いいたします。


追記:functions.php

php

1<?php 2/** 3 * themefile functions and definitions 4 * 5 * @link https://developer.wordpress.org/themes/basics/theme-functions/ 6 * 7 * @package themefile 8 */ 9 10if ( ! function_exists( 'themefile_setup' ) ) : 11/** 12 * Sets up theme defaults and registers support for various WordPress features. 13 * 14 * Note that this function is hooked into the after_setup_theme hook, which 15 * runs before the init hook. The init hook is too late for some features, such 16 * as indicating support for post thumbnails. 17 */ 18function themefile_setup() { 19 /* 20 * Make theme available for translation. 21 * Translations can be filed in the /languages/ directory. 22 * If you're building a theme based on themefile, use a find and replace 23 * to change 'themefile' to the name of your theme in all the template files. 24 */ 25 load_theme_textdomain( 'themefile', get_template_directory() . '/languages' ); 26 27 // Add default posts and comments RSS feed links to head. 28 add_theme_support( 'automatic-feed-links' ); 29 30 /* 31 * Let WordPress manage the document title. 32 * By adding theme support, we declare that this theme does not use a 33 * hard-coded <title> tag in the document head, and expect WordPress to 34 * provide it for us. 35 */ 36 add_theme_support( 'title-tag' ); 37 38 /* 39 * Enable support for Post Thumbnails on posts and pages. 40 * 41 * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ 42 */ 43 add_theme_support( 'post-thumbnails' ); 44 45 // This theme uses wp_nav_menu() in one location. 46 register_nav_menus( array( 47 'menu-1' => esc_html__( 'Primary', 'themefile' ), 48 ) ); 49 50 /* 51 * Switch default core markup for search form, comment form, and comments 52 * to output valid HTML5. 53 */ 54 add_theme_support( 'html5', array( 55 'search-form', 56 'comment-form', 57 'comment-list', 58 'gallery', 59 'caption', 60 ) ); 61 62 // Set up the WordPress core custom background feature. 63 add_theme_support( 'custom-background', apply_filters( 'themefile_custom_background_args', array( 64 'default-color' => 'ffffff', 65 'default-image' => '', 66 ) ) ); 67 68 // Add theme support for selective refresh for widgets. 69 add_theme_support( 'customize-selective-refresh-widgets' ); 70 71 /** 72 * Add support for core custom logo. 73 * 74 * @link https://codex.wordpress.org/Theme_Logo 75 */ 76 add_theme_support( 'custom-logo', array( 77 'height' => 250, 78 'width' => 250, 79 'flex-width' => true, 80 'flex-height' => true, 81 ) ); 82} 83endif; 84add_action( 'after_setup_theme', 'themefile_setup' ); 85 86/** 87 * Set the content width in pixels, based on the theme's design and stylesheet. 88 * 89 * Priority 0 to make it available to lower priority callbacks. 90 * 91 * @global int $content_width 92 */ 93function themefile_content_width() { 94 // This variable is intended to be overruled from themes. 95 // Open WPCS issue: {@link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1043}. 96 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound 97 $GLOBALS['content_width'] = apply_filters( 'themefile_content_width', 640 ); 98} 99add_action( 'after_setup_theme', 'themefile_content_width', 0 ); 100 101/** 102 * Register widget area. 103 * 104 * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar 105 */ 106function themefile_widgets_init() { 107 register_sidebar( array( 108 'name' => esc_html__( 'Sidebar', 'themefile' ), 109 'id' => 'sidebar-1', 110 'description' => esc_html__( 'Add widgets here.', 'themefile' ), 111 'before_widget' => '<section id="%1$s" class="widget %2$s">', 112 'after_widget' => '</section>', 113 'before_title' => '<h2 class="widget-title">', 114 'after_title' => '</h2>', 115 ) ); 116} 117add_action( 'widgets_init', 'themefile_widgets_init' ); 118 119/** 120 * Enqueue scripts and styles. 121 */ 122function themefile_scripts() { 123 //wp_enqueue_style( 'themefile-style', get_stylesheet_uri() ); 124 125 wp_enqueue_script( 'themefile-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true ); 126 127 wp_enqueue_script( 'themefile-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true ); 128 129 if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { 130 wp_enqueue_script( 'comment-reply' ); 131 } 132} 133add_action( 'wp_enqueue_scripts', 'themefile_scripts' ); 134 135/** 136 * Implement the Custom Header feature. 137 */ 138require get_template_directory() . '/inc/custom-header.php'; 139 140/** 141 * Custom template tags for this theme. 142 */ 143require get_template_directory() . '/inc/template-tags.php'; 144 145/** 146 * Functions which enhance the theme by hooking into WordPress. 147 */ 148require get_template_directory() . '/inc/template-functions.php'; 149 150/** 151 * Customizer additions. 152 */ 153require get_template_directory() . '/inc/customizer.php'; 154 155/** 156 * Load Jetpack compatibility file. 157 */ 158if ( defined( 'JETPACK__VERSION' ) ) { 159 require get_template_directory() . '/inc/jetpack.php'; 160} 161 162 163//固定ページの親ページをスラッグ判定 164function is_parent_slug() { 165 global $post; 166 if ($post->post_parent) { 167 $post_data = get_post($post->post_parent); 168 return $post_data->post_name; 169 } 170} 171 172/* 投稿アーカイブページの作成 */ 173function post_has_archive( $args, $post_type ) { 174 175 if ( 'post' == $post_type ) { 176 $args['rewrite'] = true; 177 $args['has_archive'] = 'news'; //任意のスラッグ名 178 } 179 return $args; 180 181} 182add_filter( 'register_post_type_args', 'post_has_archive', 10, 2 ); 183 184 185

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

madone99

2019/12/18 04:10

ログイン画面からリダイレクトされた時のURLは https://ドメイン名/wp-login.php?redirect_to=http%3A%2F%2Fドメイン名%2Fwp%2Fwp-admin%2F&reauth=1 でしょうか?
qpooooh

2019/12/18 04:36

http://ドメイン名/wp-login.php?redirect_to=http%3A%2F%2Fドメイン名%2Fwp-admin%2F&reauth=1 となっております。
madone99

2019/12/18 05:28

ありがとうございます。そちらの方は恐らく問題ないかと思います。 .htaccessのステージング->本番へのRewrite箇所は質問へご提示可能でしょうか?
qpooooh

2019/12/18 05:49

ありがとうございます。 .htaccessのリライト箇所は下記となります。 RewriteBaseとRewriteRuleを変更しました。 ==本番== # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress ==ステージング== # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /test/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /test/index.php [L] </IfModule> # END WordPress
guest

回答2

0

functions.phpに以下を追加するとどうでしょうか?
(リダイレクトループになったら消して下さい。)

php

1function login_redirect() { 2 wp_safe_redirect("本番環境URL/wp-admin/"); 3 exit(); 4} 5add_action('wp_login', 'login_redirect');

追記
functions.phpに以下のコードを追加頂いて、リダイレクトを停止するとどうなるでしょうか?

php

1remove_action('template_redirect', 'redirect_canonical');

投稿2019/12/18 07:45

編集2019/12/19 06:38
madone99

総合スコア1855

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

qpooooh

2019/12/19 00:46

ご回答ありがとうございます! 試してみましたが、ログイン後もログイン画面が表示されました。
madone99

2019/12/19 01:43

あとはCookieやブラウザのキャッシュの削除、/wp-admin/からログインするなどをお試し頂くか でしょうか。
qpooooh

2019/12/19 06:22

ご助言ありがとうございます。 すべて試してみましたが、解決には至らず…。
madone99

2019/12/19 06:39

回答の方へfunctions.phpへ追記するコードを書きました。
qpooooh

2019/12/19 06:51

ありがとうございます。 下記4パターン試しましたが、変化はありませんでした。 ①functions.php上部にremove_actionのみ追加 →サイトのTOPページでリダイレクト ②functions.php上部にlogin_redirect()remove_actionを追加 →ログイン後もログイン画面へリダイレクト ③functions.php最下部にremove_actionのみ追加 →サイトのTOPページでリダイレクト(①と同様) ④functions.php最下部にlogin_redirect()remove_actionを追加 →ログイン後もログイン画面へリダイレクト(②と同様)
madone99

2019/12/19 07:01

そうなんですね。 いったん、login_redirect()とremove_action()の方は削除頂いて、 ちなみになんですが、functions.phpの全文を質問文の方へ追加頂くことは可能でしょうか?
qpooooh

2019/12/19 07:36

ありがとうございます。 functions.phpの全文を質問の方へ追記いたしました。
madone99

2019/12/19 08:26

ありがとうございました。 jetpackというプラグインを使用されていると思うのですが、 他に利用されているプラグインはありますか? また、このテーマファイルは独自に作成されたものになりますでしょうか。
qpooooh

2019/12/19 08:52

使用しているプラグインは複数ございますが、 FTP上で「/wp-content/plugins」の「plugins」のディレクトリ名を変更してもログインできませんでした。 以下、FTP上にアップロードされているプラグインです。 akismet all-in-one-wp-migration all-in-one-wp-security-and-firewall autoptimize classic-editor disable-google-fonts imagemagick-engine protect-uploads remove-query-strings-from-static-resources sakura-rs-wp-ssl ts-webfonts-for-sakura wordpress-seo wp-multibyte-patch また、テーマファイルは下記をベースにした独自テーマとなります。 https://underscores.me/
madone99

2019/12/20 01:21

プラグインで何かしらリダイレクトを行っているかの切り分けは それで良いと思います。 (all-in-one-wp-security-and-firewallでログインを制限できる機能がありますが 指定していればエラーになったと思います。) テーマも方も問題無いかと思いますので、 後はhttpとhttpsのプロトコルの付け違いくらいしか思い浮かびませんでした。
guest

0

サイト URL の変更 - WordPress Codex 日本語版
こちらの手順を試してください。

テーマのfunctions.phpの冒頭

PHP

1<?php 2update_option( 'siteurl', 'https://example.com' ); 3update_option( 'home', 'https://example.com' );

wp-config.php

PHP

1define('RELOCATE',true);

https://example.org/wp-login.php へアクセス

投稿2019/12/18 03:50

Takumiboo

総合スコア2534

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

qpooooh

2019/12/18 04:39 編集

ご回答ありがとうございます。 早速試してみましたが、解決に至りませんでした…
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問