我可以用mod_rewrite重写forum.mydomain.org到mydomain.org/forum/吗?
因为我不能让子域名工作
– 更新 –
对不起克里斯,你的答案没有工作。
我的域名有一个名为forum的子域名,里面有我的IPlogging
127.0.0.1 localhost 127.0.0.1 forum
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot "c:/wamp/www" ServerName localhost ErrorLog "logs/localhost-error.log" CustomLog "logs/localhost-access.log" common </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot "c:/wamp/www/forum" ServerName forum ErrorLog "logs/your_own-error.log" CustomLog "logs/your_own-access.log" common </VirtualHost>
是的,你可以,但你不需要。 只需使用redirect:
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName forum.mydomain.org ErrorLog "logs/your_own-error.log" CustomLog "logs/your_own-access.log" common Redirect Permanent http://www.mydomain.org/forum/ </VirtualHost>
看一下你发布的configuration,
可能发生的事情是,当你尝试击中forum.mydomain.org它不匹配任何虚拟主机(因为它没有被定义)。 所以apache使用默认的VirtualHost,我相信这是你定义的第一个VirtualHost。
首先是可以使用redirect,但更重要的是为什么不能让子域名工作? 你遇到什么问题?
更详细的一点,我可以帮助你的最佳解决scheme。
DC
如果您“禁止”您可以排除DNS问题。 这似乎是你有一个configuration问题。 很可能你还没有定义一个默认页面,幻想索引被禁用。
尝试添加到httpd.conf
<IfModule mod_autoindex.c> IndexOptions FancyIndexing </ifModule>
并确保mod_autoindex已加载
看看你的虚拟服务器configuration子域。 比较它为您的主域的一个。
请记住,虚拟服务器会覆盖主configuration,换句话说,如果在主configuration部分(外部的任何地方)中定义了某个虚拟服务器,它将继续对您的虚拟主机有效。 所以要么在httpd.conf的主要部分中更改它,要么将其添加到您的虚拟主机中。
也许如果你发布你的configuration(只是虚拟服务器的相关部分),我们可以build议改变
DC
你的Virtualserverconfiguration看起来不错。
没有看到更多的configuration,我会冒险猜测问题是与论坛软件。 如果你可以通过localhost / forum / index.php进入论坛,而不是forum / index.php那么我会说论坛软件被configuration为使用不正确的域名。 可能它被设置为使用localhost而不是论坛作为域名。 而且可能它也被configuration为使用目录/ forum /而不是根文件夹
这只是猜测,因为它很难确定的确切原因没有仔细看。
如果您创build一个名为/forum/test.html的文件,您可以使用http://forum/test.html来访问它。
您可能需要将任何.htaccess文件重命名为disabled.htaccess,以免干扰。 重命名path中的所有.htaccess文件,例如:如果存在C:\ wamp \ www中的其中一个
DC