0

I am working on a Multisite that was installed and activated on an old version of WordPress. The WP files were placed in a subdirectory named /wp/ and now a request has been made for the subdirectory to be removed from the URL, i.e. the site's and subsites' web addresses should be domain.com, domain.com/subsite and not domain.com/wp/, domain.com/wp/subsite.

Rather than moving the WordPress files out of the /wp/ subdirectory, can I use a rewrite rule in the .htaccess file to make it such that the URL shows https://domain.com and https://domain.com/subsite/pages and serve the content from https://domain.com/wp/ and https://domain.com/wp/subsite/pages?

The comment given for a similar question (Suppress subdirectory from Wordpress Multisite primary URL) referenced the codex but this multisite was installed and activated with a version older than 3.5 and looks like SubFolder Example - WordPress 3.0 through 3.4.2 containing these lines, which do not appear in Method I (Without URL change):

#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteRule ^(.*/)?files/(.*) wp-includes/ms-files.php?file=$2 [L]

Can I follow the codex entry and replace my current htaccess file with the version shown in Method I (Without URL change)?

I also spoke with the hosting provider's tech support and their recommendation was to do the reverse: rather than move the WP files from the root folder to the subdirectory their suggested course of action was to move all the files in the subdirectory into the root and make further changes using PhpMyAdmin.

I've combed through the WordPress Stack Exchange, web articles and the Codex and am having a difficult time deciding on a course of action.

Edit: additional information

In the document root, there exist:

-htaccess file

RewriteEngine on

RewriteOptions inherit

 <Files php.ini>
   order allow,deny
   deny from all
 </Files>

#ErrorDocument 404 http://www.domain.org/wp/page-not-found/

# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php5_module>
   php_value max_input_vars 3000
   php_value memory_limit 512M
   php_flag asp_tags Off
   php_flag display_errors Off
   php_value max_execution_time 180
   php_value max_input_time 180
   php_value post_max_size 256M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/tmp"
   php_value upload_max_filesize 256M
   php_flag zlib.output_compression Off
</IfModule>
# END cPanel-generated php ini directives, do not edit

# php -- BEGIN cPanel-generated handler, do not edit
# This domain inherits the “PHP” package.
# php -- END cPanel-generated handler, do not edit
#ewriteCond %{HTTP_HOST} ^domain\.org$ [OR]
#ewriteCond %{HTTP_HOST} ^www\.domain\.org$
#ewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
#ewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
#RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
#RewriteRule ^/?$ "https\:\/\/www\.domain\.org\/wp\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^domain\.org$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.org$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ce$ "http\:\/\/www\.domain\.org\/wp\/ce" [R=301,L]
RewriteCond %{HTTP_HOST} ^domain\.org$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.org$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^cte$ "http\:\/\/www\.domain\.org\/wp\/ce" [R=301,L]
RewriteCond %{HTTP_HOST} ^domain\.org$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.org$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^CE$ "http\:\/\/www\.domain\.org\/wp\/ce" [R=301,L]

-index.php (note the closing php tag)

<?php
/**
 * Front to the WordPress application. This file doesn't do anything, but loads
 * wp-blog-header.php which does and tells WordPress to load the theme.
 *
 * @package WordPress
 */

/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require('./wp/wp-blog-header.php');
?>

-other files: user.ini, php.ini, phpinfo.php, robots.txt

In the /wp/ folder, there also exist htaccess file and index.php that look more like the standard files:

-htaccess

#AddHandler application/x-httpd-php54 .php
RewriteEngine On
RewriteBase /wp/

# BEGIN WPSuperCache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteBase /wp/
#If you serve pages from behind a proxy you may want to change 'RewriteCond %{HTTPS} on' to something more sensible
AddDefaultCharset UTF-8
RewriteCond %{REQUEST_URI} !^.*[^/]$
RewriteCond %{REQUEST_URI} !^.*//.*$
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$
RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{HTTPS} on
RewriteCond %{DOCUMENT_ROOT}/wp/wp-content/cache/supercache/%{SERVER_NAME}/wp/$1/index-https.html.gz -f
RewriteRule ^(.*) "/wp/wp-content/cache/supercache/%{SERVER_NAME}/wp/$1/index-https.html.gz" [L]

RewriteCond %{REQUEST_URI} !^.*[^/]$
RewriteCond %{REQUEST_URI} !^.*//.*$
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$
RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{HTTPS} !on
RewriteCond %{DOCUMENT_ROOT}/wp/wp-content/cache/supercache/%{SERVER_NAME}/wp/$1/index.html.gz -f
RewriteRule ^(.*) "/wp/wp-content/cache/supercache/%{SERVER_NAME}/wp/$1/index.html.gz" [L]

RewriteCond %{REQUEST_URI} !^.*[^/]$
RewriteCond %{REQUEST_URI} !^.*//.*$
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$
RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{HTTPS} on
RewriteCond %{DOCUMENT_ROOT}/wp/wp-content/cache/supercache/%{SERVER_NAME}/wp/$1/index-https.html -f
RewriteRule ^(.*) "/wp/wp-content/cache/supercache/%{SERVER_NAME}/wp/$1/index-https.html" [L]

RewriteCond %{REQUEST_URI} !^.*[^/]$
RewriteCond %{REQUEST_URI} !^.*//.*$
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$
RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{HTTPS} !on
RewriteCond %{DOCUMENT_ROOT}/wp/wp-content/cache/supercache/%{SERVER_NAME}/wp/$1/index.html -f
RewriteRule ^(.*) "/wp/wp-content/cache/supercache/%{SERVER_NAME}/wp/$1/index.html" [L]
</IfModule>

# END WPSuperCache

#BEGIN WordPress
#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteRule ^(.*/)?files/(.*) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteCond %{REQUEST_URI} ^.*/wp-admin$
RewriteRule ^(.+)$ $1/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
# END Wordpress

<IfModule mod_security.c>
<Files async-upload.php>
SecFilterEngine Off
SecFilterScanPOST Off
</Files>
</IfModule>



# BEGIN WordPress

# END WordPress

-index.php (no closing tag at end of file)

<?php
/**
 * Front to the WordPress application. This file doesn't do anything, but loads
 * wp-blog-header.php which does and tells WordPress to load the theme.
 *
 * @package WordPress
 */

/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
  • +1000 for moving everything into the root. – leymannx Apr 16 at 7:25
  • 1
    Please include the contents of your .htaccess file. Do you have anything else in the document root of the site? – MrWhite Apr 16 at 7:38
  • @MrWhite Listed the additional files found in the root. – cseto Apr 16 at 17:26

Your Answer

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

Browse other questions tagged or ask your own question.