2013-08-26 89 views
0

我有一个位于服务器公共根目录的index.php站点。如何更改站点路径和使用htaccess创建子域

的网址是

http://example.com 

我创建了一个名为“旅行”子文件夹,移动整个网站内容到它。

使用的.htaccess,我怎么能有我的网站现在这个ADRESS(与子域旅游):

http://travel.example.com 

回答

1

为什么htaccess以及为什么在Apache的配置不只是虚拟主机条目是这样的:

<VirtualHost *:80> 
    ServerName www.example.com 
    ServerAlias example.com 
    DocumentRoot /www/domain 
</VirtualHost> 

<VirtualHost *:80> 
    ServerName travel.example.com 
    DocumentRoot /www/domain/travel 
</VirtualHost> 

基于EDIT htaccess的溶液:

启用mod_rewrite的和通过htaccess的3210,然后把这个代码在你.htaccessDOCUMENT_ROOT目录:

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 
RewriteBase/

RewriteCond %{HTTP_HOST} ^travel\.example\.com$ [NC] 
RewriteRule (?!travel/)^(.*)$ travel/$1 [L,NC] 
+0

该网站是在PaaS的托管和我恐怕不能访问到服务器的conf。 – Matoeil

+0

“travel.example.com”目前指向哪里?它是否从服务器公共根打开相同的'index.php'? – anubhava