我想通过子目录运行 WordPress 网站,但保留实际域。
这就是我正在尝试做的事情。
假设我有一个网站 www.xyz.com
我在根目录安装了一个wordpress实例。但是,我想在子目录中安装一个新的 WordPress 实例。我想将 root worpdress 实例指向子目录并保留域名而不引用子目录。
子目录可以称为“test”。在测试目录中,我将安装一个新的 WordPress 实例。
现在,我想将 www.xyz.com 指向“test”目录,并且链接仍然为 www.xyz.com。所有链接都应该是 www.xyz.com/post-name-sample 而不是 www.xyz.com/test/post-name-sample。
我需要在 .htaccess 文件中设置 mod 重写规则吗?
任何帮助都是值得赞赏的。谢谢!
尝试将其添加到 .htaccess 文件中
.htaccess main domain to subfolder redirect
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.
# Do not change this line.
RewriteEngine on
# Change yourdomain.co.uk to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.co.uk$
# Change ‘subfolder’ to be the folder you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subfolder/
# Don’t change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change ‘subfolder’ to be the folder you will use for your main domain.
RewriteRule ^(.*)$ /subfolder/$1
# Change yourdomain.co.uk to be your main domain again.
# Change ‘subfolder’ to be the folder you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.co.uk$
RewriteRule ^(/)?$ subfolder/index.php [L]
可以在 WordPress 上使用:这里是如果您已经将其安装在子目录中的话如何操作。
require( dirname( __FILE__
) . '/wp-blog-header.php' );
的行更改为以下内容
WordPress 核心文件的名称:require( dirname( __FILE__ ) .
'/wordpress/wp-blog-header.php' );
Please change or delete .htaccess file and change link in wp_option table and change link from siteurl and home url