The blog is available at http://www.example.com/blog
. The login url is accessible at http://www.example.com/blog/wp-login.php
. But once logged in, the browser briefly shows http://www.example.com/blog/wp-admin/
in the url field and then redirects and finally shows the dashboard at the url http://www.example.com/wp-admin/
.
该博客位于http://www.example.com/blog。登录URL可在http://www.example.com/blog/wp-login.php*问。但登录后,浏览器会在网址字段中简要显示http://www.example.com/blog/wp-admin/,然后重定向,最后在网址http://www.example.com/上显示信息中心可湿性粉剂管理员/。
The Problem
Now all the url in the wordpress dashboard (eg: posts, pages, settings etc) are of the form http://www.example.com/wp-admin/xxx.php
instead of the desired http://www.example.com/blog/wp-admin/xxx.php
. When I click any of these links, the request goes to the rails app which throws an error as it obviously doesn't know this wp-admin
path.
现在wordpress仪表板中的所有URL(例如:帖子,页面,设置等)都是http://www.example.com/wp-admin/xxx.php,而不是所需的http://www.example .COM /博客/可湿性粉剂管理员/ xxx.php。当我点击这些链接中的任何一个时,请求会转到rails应用程序,它会抛出一个错误,因为它显然不知道这个wp-admin路径。
I have set the following in the wordpress' wp-config.php
file:
我在wordpress的'wp-config.php文件中设置了以下内容:
define('WP_HOME','http://www.example.com/blog');
define('WP_SITEURL','http://www.example.com/blog');
The apache conf file of the rails app has this reverse proxy setting:
rails app的apache conf文件具有以下反向代理设置:
ProxyPass /blog http://www.example.com:8080
ProxyPassReverse /blog http://www.example.com:8080
(yes, the wordpress is made to listen in another port)
(是的,wordpress是在另一个端口监听)
This is the .htaccess
file I have in the wordpress root directory:
这是我在wordpress根目录中的.htaccess文件:
Options +FollowSymlinks
RewriteEngine on
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
The Confusion
I have very little knowledge of how htaccess works. But what's crazy is, this is based on another app(rails+wp) that's working with these exact same setup.
我对htaccess的工作方式知之甚少。但令人抓狂的是,这是基于另一个应用程序(rails + wp)正在使用这些完全相同的设置。
The only difference between the working and not-working apps(above) is that, the working site has no www
in its root url as well as in its blog url. Could that be playing any hand here?
工作和不工作应用程序(上图)之间的唯一区别是,工作站点的根URL和博客URL中没有www。这可以在这里玩吗?
Any help is much appreciated as I'm struggling with it for weeks.
任何帮助都非常感激,因为我已经挣扎了几个星期。
I'd be glad to furnish more details if you need them.
如果您需要,我很乐意提供更多细节。
PS: There's no .htaccess
file in the public folder of the rails app. The above mentioned htaccess file is present at the wordpress folder's root location.
PS:rails app的公共文件夹中没有.htaccess文件。上面提到的htaccess文件出现在wordpress文件夹的根位置。
1 个解决方案
#1
You need to change the database URL - WordPress stores the URL in the database in many places. Check https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ as an example of how to find/replace. Otherwise you can also go into the database and change it in the wp_options table, which might be enough for you to get in. Read up on how to change the URL: https://codex.wordpress.org/Changing_The_Site_URL and try acting like you're changing from the wrong one to the right one, and it will likely fix the issue.
您需要更改数据库URL - WordPress将URL存储在许多地方的数据库中。检查https://interconnectit.com/products/search-and-replace-for-wordpress-databases/作为如何查找/替换的示例。否则你也可以进入数据库并在wp_options表中更改它,这可能足以让你进入。阅读如何更改URL:https://codex.wordpress.org/Changing_The_Site_URL并尝试表现得像你正在从错误的一个变为正确的一个,它可能会解决问题。
#1
You need to change the database URL - WordPress stores the URL in the database in many places. Check https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ as an example of how to find/replace. Otherwise you can also go into the database and change it in the wp_options table, which might be enough for you to get in. Read up on how to change the URL: https://codex.wordpress.org/Changing_The_Site_URL and try acting like you're changing from the wrong one to the right one, and it will likely fix the issue.
您需要更改数据库URL - WordPress将URL存储在许多地方的数据库中。检查https://interconnectit.com/products/search-and-replace-for-wordpress-databases/作为如何查找/替换的示例。否则你也可以进入数据库并在wp_options表中更改它,这可能足以让你进入。阅读如何更改URL:https://codex.wordpress.org/Changing_The_Site_URL并尝试表现得像你正在从错误的一个变为正确的一个,它可能会解决问题。