0

I am setting wordpress in a custom way and having issues with renaming wp-content. Here are the details:

I am using Amazon AWS as my environment. The default web root is /var/www/html/. Within that directory, I have multiple projects, each having its own directory. So, my WordPress project is in /var/www/html/project01. So this leads to accessing the WordPress from the web browser via the following URL: http://some-url.com/project01/index.php.

The next step, I typically move WordPress files into a sub-directory. So, I moved all wordpress files into a directory named red inside /var/www/html/project01 then copied index.php from that sub-directory back into the project01 directory, and modified index.php as follows:

require( dirname( __FILE__ ) . '/red/wp-blog-header.php' );

This resulted in the following directory structure:

/var/www/html
          |
          --------project01
                     |
                     -------- index.php /* modified as described above */
                     |
                     -------- red
                               |
                               -------- wp-config.php
                               |
                               -------- wp-content
                               |
                               -------- /* Other WordPress files and directories */

So far, everythig works great and without a problem. I can access both the front end and the admin area of the site.

The next step in my setup is to rename wp-content to something else as an added security measure. So, I renamed wp-content to green. So my directory structure now looks like this:

/var/www/html
          |
          --------project01
                     |
                     -------- index.php /* modified as described above */
                     |
                     -------- red
                               |
                               -------- wp-config.php
                               |
                               -------- green /* this is a renamed wp-content directory */
                               |
                               -------- /* Other WordPress files and directories */

To complete the directory rename, wp-config.php should be updated to reflect the changes made, so, I followed the instructions described here and added the following to wp-config.php:

define('WP_CONTENT_FOLDERNAME', 'green');
define('WP_CONTENT_DIR', ABSPATH . WP_CONTENT_FOLDERNAME);

define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/');
define('WP_CONTENT_URL', WP_SITEURL . 'project01' . '/' . 'red' . '/' . WP_CONTENT_FOLDERNAME);

I added the above code just before the following line in wp-config.php:

require_once(ABSPATH . 'wp-settings.php');

IMPORTANT: Please also note that the WP_CONTENT_URL parameter that I added in wp-config.php is set to include the changes in the directory strucuture described above.

Now, after doing so, if I go to http://some-url.com/project01/index.php, everything is fine and the site's front-end is displayed properly. However, if I go to http://some-url.com/project01/red/green/wp-admin to login to the admin area, the page is redirected to http://some-url.com/wp-login.php as opposed to http://some-url.com/project01/red/green/wp-login.php, and I get a 404 error.

So, my question is, what did I miss? What do I have to do to fix this problem? Is there a setup I have to do in .htaccess for example? Something else? Your help is greatly appreciated.

Thanks.

2

Just FYI:

After struggling for hours, I found the aswer. The line that was causing the problem is the following in my wp-config.php file:

define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/');

It turned out my WP_SITEURL is not working correctly because I changed the directory structure as described in the question. So I modified wp-config.php and it now looks like this:

define('WP_CONTENT_FOLDERNAME', 'green');
define('WP_CONTENT_DIR', ABSPATH . WP_CONTENT_FOLDERNAME);

define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/project01/');
define('WP_SITEURL', WP_HOME .  'red/');
define('WP_CONTENT_URL', WP_SITEURL . WP_CONTENT_FOLDERNAME);

Now, it works like a charm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.