保持域名htaccess

时间:2013-09-15 09:17:48

标签: apache .htaccess redirect mod-rewrite

我有点问题。我有一个piensasolutions和两个域的托管。第一个域控制托管,第二个域使用域名停放。

a.com成为第一个域,b.com成为第二个域。

b.com的域名停放允许我从b.com重定向到a.com/folder,(其中文件夹包含我要用b.com指向的网页)。< / p>

问题是我想显示b.com网址而不是a.com/folder网址,我不确定问题是否来自piensasolutions,因为我尝试了几个.htaccess文件,但我无法更改Web浏览器的URL。这是我最后一次考虑保留原始网址的测试。

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www.)?a.com/folder/$ 
RewriteRule ^(.*)$ /a.com/folder/$1 [L]

RewriteCond %{HTTP_HOST} ^(www.)?b.com$
RewriteRule ^(.*)$ /b.com/$1 [L]

有关其他信息,我将.htaccess文件放在a.com/folder中。我不确定piensasolutions的重定向。

如果你能帮助我,我会非常感激,即使你没有找到你的,也会有几分钟的时间。

谢谢!

1 个答案:

答案 0 :(得分:0)

我认为最好的方法是usig sites-avaiable。 首先,

$ vi /etc/host

并复制下一行:

127.0.0.1   a
127.0.0.1   b

然后,创建两个新站点:

$ touch /etc/apache2/sites-avaiable/a
$ touch /etc/apache2/sites-avaiable/b

并编辑它们

$ vi /etc/apache2/sites-avaiables/a


<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName a
DocumentRoot /your_path_to_server/a/folder
    <Directory /your_path_to_server/a/folder/>
                    Options FollowSymLinks
                    AllowOverride All          
                    Require all granted
    </Directory>
</VirtualHost>

$ vi /etc/apache2/sites-avaiables/b


<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName b
DocumentRoot /your_path_to_server/b
    <Directory /your_path_to_server/b/>
                    Options FollowSymLinks
                    AllowOverride All          
                    Require all granted
    </Directory>
</VirtualHost>

就是这样。这应该有用。