Moving WordPress directory (to root) per codex instructions causes multiple 404s
-
I know, this sounds like a newb error. But the codex instructions are simple and I executed them successfully just 6 months ago on a client site. But this week I have tried it in two different locations with failure: a new site, and on a localhost installation. Both are running Apache. My local install is on OS X 10.11.6.
Here are the steps:
1) In Dashboard->Settings, change the WordPress Address (URL) to root, i.e. https://sitename.com/wp –> https://sitename.com
2) Do the same under Site Address (URL).
3) Submit. Ignore error message.
4) Copy index.php and .htaccess to root directory. Change index.php to refer to the subdirectory containing the installation.
require( dirname( __FILE__ ) . '/wp/wp-blog-header.php' );
The site now loads some front page content, but on a white page with no styling. It looks like it is half-transferred. The browser status bar is quite active, sending multiple requests, but nothing visibly changes. This is explained by access-log, showing multiple 404s for things that should be working now, starting with:
POST /wp-cron.php?doing_wp_cron=1473357879.5045380592346191406250 HTTP/1.1" 404 18444
Some other key 404s include (but are by no means limited to):
GET /wp-content/themes/mythemename/css/mythemename.css?ver=1.0.0 HTTP/1.1" 404 19965 GET /wp-includes/js/jquery/jquery.js?ver=1.12.4 HTTP/1.1" 404 19950
Now, I thought the culprit might be the url redirection, so I turned on trace6 for mod_rewrite in the virtual host configuration in the localhost site. The redirection appears to be successful. For example:
[Thu Sep 08 12:04:39.524223 2016] [rewrite:trace3] [pid 7032] mod_rewrite.c(476): [client 127.0.0.1:52145] 127.0.0.1 - - [prfol.localhost/sid#7f883c020c40 ][rid#7f883c042780/initial/redir#1] [perdir /Users/david/Sites/prfol/public_html/] strip per-dir prefix: /Users/david/Sites/prfol/public_html/index.php -> index.php, referer: https://prfol.localhost/wp-cron.php?doing_wp_cron=1473357879.5045380592346191406250 [Thu Sep 08 12:04:39.524236 2016] [rewrite:trace3] [pid 7032] mod_rewrite.c(476): [client 127.0.0.1:52145] 127.0.0.1 - - [prfol.localhost/sid#7f883c020c40 ][rid#7f883c042780/initial/redir#1] [perdir /Users/david/Sites/prfol/public_html/] applying pattern '^index\\.php$' to uri 'index.php', referer: https://pr fol.localhost/wp-cron.php?doing_wp_cron=1473357879.5045380592346191406250 [Thu Sep 08 12:04:39.524249 2016] [rewrite:trace1] [pid 7032] mod_rewrite.c(476): [client 127.0.0.1:52145] 127.0.0.1 - - [prfol.localhost/sid#7f883c020c40 ][rid#7f883c042780/initial/redir#1] [perdir /Users/david/Sites/prfol/public_html/] pass through /Users/david/Sites/prfol/public_html/index.php, referer: h ttp://prfol.localhost/wp-cron.php?doing_wp_cron=1473357879.5045380592346191406250
However, I still get the 404 for the top line of this request.
I’ve tried hard refreshes. Clearing the cache. Even using a new browser that has never visited the site.My .htaccess:
# 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
My httpd-vhosts.conf for this site:
<VirtualHost *:80> ServerAdmin [my email] DocumentRoot "/Users/david/Sites/prfol/public_html" ServerName prfol.localhost ServerAlias www.prfol.localhost ErrorLog "/private/var/log/apache2/prfol-error_log" CustomLog "/private/var/log/apache2/prfol-access_log" common LogLevel debug rewrite:trace6 </VirtualHost> <Directory "/Users/david/Sites/prfol/public_html"> Options FollowSymLinks Multiviews MultiviewsMatch Any AllowOverride All Require all granted </Directory>
After writing this, I realize that WordPress apparently requests its normal URLs, apache applies the redirect rules on them, but then something doesn’t complete.
I’m still convinced that it’s something I have overlooked or skipped. I’m able to revert to the subdirectory by restoring the WordPress Address and Site Address values via phpmyadmin, and deleting the root-level index.php and .htaccess.
Can anyone see what I’m missing? Or else help me find how the redirect is not executed? Perhaps by setting trace on another module?
Thank you!
- The topic ‘Moving WordPress directory (to root) per codex instructions causes multiple 404s’ is closed to new replies.