admin管理员组文章数量:1432164
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
, domain/subsite
and not domain/wp/
, domain/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 and
and serve the content from
/
and ?
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 /
# 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 ()
<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\$ [OR]
#ewriteCond %{HTTP_HOST} ^www\.domain\$
#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\\/wp\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^domain\$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\$
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\\/wp\/ce" [R=301,L]
RewriteCond %{HTTP_HOST} ^domain\$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\$
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\\/wp\/ce" [R=301,L]
RewriteCond %{HTTP_HOST} ^domain\$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\$
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\\/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' );
本文标签: Can I add a rewrite rule in htaccess to remove the multisite subdirectory from the URL
版权声明:本文标题:Can I add a rewrite rule in htaccess to remove the multisite subdirectory from the URL? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745582681a2664712.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论