在子文件夹问题中安装第二个WordPress实例

问题描述 投票:0回答:1

我有一个共享的Linux主机,我想在其上托管2个网站。 在/public_html/我接待了example.com,在/public_html/example2/我接待了example2.com

example.com的.htaccess

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

#Custom Error Pages
ErrorDocument 403 https://www.example.com/error-403/

example2.com的.htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

#Custom Error Pages
ErrorDocument 403 http://www.example2.com/error-403/

我想用www版本分别访问这两个网站,即

请注意:我在WordPress常规设置中设置了site_urlhome_url及以上给定的URL。

我面临的问题是

当我访问example2.com时它带我去https://www.example.com/example2/

所以在阅读this answer之后,我改变了.htaccessexample.com

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^index\.php$ - [L]

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# if request is not for the /example2/
RewriteCond %{REQUEST_URI} !^/example2/ [NC]

# otherwise forward it to index.php
RewriteRule . /index.php [L]

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
</IfModule>
# END WordPress

所以现在example2.com是可访问的,但永久链接不起作用所以当我尝试重置它时,它正在删除我的example2 .haccess文件的内容并将我重定向到https://www.example.com/example2/

有人可以帮我从这里出去吗?

我也试过没有运气Configuring WordPress .htaccess to view subfolders

wordpress apache .htaccess mod-rewrite
1个回答
0
投票

我认为例2的htaccess应该是这样的:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
 RewriteBase /example2
 RewriteRule ^index\.php$ - [L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule . /index.php [L]
 </IfModule>
 # END WordPress

 #Custom Error Pages
 ErrorDocument 403 http://www.example2.com/error-403/
© www.soinside.com 2019 - 2024. All rights reserved.