我有一个共享的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_url
和home_url
及以上给定的URL。
我面临的问题是
当我访问example2.com
时它带我去https://www.example.com/example2/
所以在阅读this answer之后,我改变了.htaccess
的example.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/
。
有人可以帮我从这里出去吗?
我认为例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/