两个域,1个共享服务器.htaccess文件

两个域,1个共享服务器.htaccess文件,.htaccess,.htaccess,我看了很多其他的“两个域,一个服务器”的问题,并没有看到我到底在寻找什么 我有两个域名,www.example1.com和www.example2.com。它们位于与apache共享的托管环境中。我想: A) example1.com加载普通index.html文件(在wordpress安装中) B) example2.com转到子文件夹/论坛/ 因此,换句话说,我希望example1.com成为我的主(正常和快乐)域,example2.com只加载/forums/目录 我想我可能只需要一个重写

我看了很多其他的“两个域,一个服务器”的问题,并没有看到我到底在寻找什么

我有两个域名,www.example1.com和www.example2.com。它们位于与apache共享的托管环境中。我想:

A) example1.com加载普通index.html文件(在wordpress安装中) B) example2.com转到子文件夹/论坛/

因此,换句话说,我希望example1.com成为我的主(正常和快乐)域,example2.com只加载/forums/目录

我想我可能只需要一个重写规则,例如2.com转到/forums/


我希望这是有道理的:)。非常感谢你能提供的任何帮助

尝试将以下内容添加到域根文件夹中的htaccess文件中

RewriteEngine on 
RewriteBase / 

#if on www.example1.com domain
RewriteCond %{HTTP_HOST} ^www\.example1\.com$ [NC]
#and not an existing file of directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#then send all requests to index.php
RewriteRule ^ index.php [L]


#if on www.example2.com domain
RewriteCond %{HTTP_HOST} ^www\.example2\.com$ [NC]
#if not already in forums directory
RewriteCond %{REQUEST_URI} !/forums/ [NC]
#rewrite requests to forums directory
RewriteRule (.*) forums/$1 [L]

也许它会对某人有用。在扫描和尝试各种方法后,下面的方法似乎工作得很好。我正在使用Apache服务器。在我的htaccess文件中,在IfModule之后我添加了
条件,它工作正常

<IfModule>
.
.
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
</IfModule>
<If "%{HTTP_HOST} == 'www.xyzs.co.uk'">

    Redirect    permanent   /xyz1   /yyy1
    Redirect    permanent   /xyz2   /yyy2
    Redirect    permanent   /xyz3   /yyy3
    Redirect    permanent   /xyz4   /yyy4
<If>

.
.
重写规则^$webroot/[L]
重写规则(.*)webroot/$1[L]
重定向永久/xyz1/yyy1
重定向永久/xyz2/yyy2
重定向永久/xyz3/YYYY3
重定向永久/xyz4/YYYY4

更多阅读:

非常感谢您的快速回复!使用您的代码,example1.com确实可以加载index.php。然而,当example2.com加载时,我得到一个404错误。有什么想法吗?哦,我是说500个内部服务器错误(不是404)。非常感谢!我明天会给它做个测试,然后回来报告。