dongnaoxia0927 2017-11-13 20:57
浏览 170

将WordPress移动到子目录url:wp-admin抛出404

I'm moving my Wordpress blog from a subdomain (where it sits at the moment) to a sudrectory of my root domain. So basically it's now in

blog.exampledomain.com

And I want it to go to

exampledomain.com/blog

I can move all the content, but wp-admin throws 404 or redirects in the wrong way. So I'm not able to manage my blog!

The things I've done:

  • In the DB: Changed siteurl to exampledomain.com
  • In the DB: Change home to exampledomain.com/blog/
  • Updated the .htaccess as follows:

    BEGIN WordPress

    RewriteEngine On RewriteBase /blog/ RewriteRule ^index.php$ - [L]

    RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule . /index.php [L]

    END WordPress

If I set it like this, the blog itself works but wp-admin throws 404. I also tried an alternative setup of .htaccess I've found around

#BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog.
RewriteRule ^index\.php$ - [L]

RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]

RewriteRule . /index.php [L]
</IfModule>

# END WordPress

This approach makes it so I'm redirected to

exampledomain.com/blog/blog/wp-admin

Which again throws 404! I'm stuck now

Additional info not sure if helpful:

  • I have an haproxy sending the traffic from the main domain to the Wordpress instance (this is why the files are on the root directory of the WP but I want a subdir URL)
  • I will change the static file URLs later from the wp-admin
  • 写回答

1条回答 默认 最新

  • dongyi1490 2019-03-27 17:34
    关注

    You have your siteurl and home the wrong way around.

    siteurl is where your Wordpress installation is (e.g. http://exampledomain.com/blog/).

    home is where the rest of your website is (e.g. http://exampledomain.com).

    Changing that should fix it. You can reset your .htaccess file and save your permalink options again to generate a new correct one (only use the multisite one, if you use multisite).

    评论

报告相同问题?

悬赏问题

  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥20 java在应用程序里获取不到扬声器设备