我想通过子目录运行wordpress网站,但保留实际域名。
这是我想要做的。
比方说,我有一个网站 www.xyz.com
我在根目录上安装了wordpress实例。但是,我想在子目录中安装一个新的wordpress实例。我想将根worpdress实例指向子目录并保留域名而不引用子目录。
可以调用子目录让我们说“测试”。在测试目录中,我将安装一个新的wordpress实例。
现在,我想将www.xyz.com指向“test”目录,并且仍然将链接指向www.xyz.com。所有链接应该是www.xyz.com/post-name-sample而不是www.xyz.com/test/post-name-sample。
我需要在.htaccess文件中设置mod重写规则吗?
任何帮助都表示赞赏。谢谢!
答案 0 :(得分:1)
尝试将此添加到.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]
答案 1 :(得分:0)
可以在wordpress上执行:here如果已经将它安装在子目录中,该怎么做呢。
require( dirname( __FILE__
) . '/wp-blog-header.php' );
的行更改为以下内容
WordPress核心文件的名称:require( dirname( __FILE__ ) .
'/wordpress/wp-blog-header.php' );