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/
.
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.
I have set the following in the wordpress’ wp-config.php
file:
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:
ProxyPass /blog http://www.example.com:8080
ProxyPassReverse /blog http://www.example.com:8080
(yes, the wordpress is made to listen in another port)
This is the .htaccess
file I have in the wordpress root directory:
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.
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?
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.
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.