【问题标题】:Installing a second WordPress instance in a subfolder issue在子文件夹问题中安装第二个 WordPress 实例
【发布时间】:2017-12-25 12:52:27
【问题描述】:

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

.htaccess of example.com

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/

.htaccess of example2.com

# 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】:

    我认为例子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/
    

    【讨论】:

    • 感谢您的回答,但它似乎无法正常工作,因为它现在正在重定向到https://www.example.com/example2/
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-20
    • 1970-01-01
    • 2017-08-18
    • 1970-01-01
    • 2017-12-04
    相关资源
    最近更新 更多