2012-02-28 106 views
1

我想在我的.htaccess文件中有一个特定的domian条件设置。我的用例是我有dev(example.dev)和live(example.com)。 htaccess文件位于我的git仓库中,但是我在.htaccess中有一些设置只适用于活动站点。理想情况下,我想有一个像下面的伪代码的条件设置:.htaccess中特定域的条件设置?

<sometag domain=my_prod_domain example.com> 

#code specific to only the live domain here 

</sometag> 

回答

3

您是否有权访问主配置文件?

如果是的话,那么你可以使用

AccessFileName .public.htaccess 

AccessFileName .dev.htaccess 

指定为不同的主机不同的配置文件,然后你可以用include指令工作负载常见的两种配置。

Include .common.htaccess 

另一个想法是尝试与IF-指令来工作,但是这一切都取决于你的访问配置的设置和级别:http://httpd.apache.org/docs/2.4/mod/core.html#if

编辑:

好吧,我想用IfDefine你可以做更多沿着你原来的线路:

开始你的开发。服务器与httpd -DDevServer,并且对你的发言是这样的:

<IfDefine DevServer> 
#Config specific for your dev. server 
</IfDefine> 

<IfDefine !DevServer> 
#Config specific for your live server. 
<IfDefine> 

对于这个解决方案,你不需要你活的服务器上,即使root访问权限。

+0

我的开发服务器在OS X中是本地的,并且运行在MAMP Pro上,所以我认为这不会起作用。 – 2012-02-28 22:37:40

+0

那么我会形象MAMP已经定义了一些变量。也许是“MAMP”? – 2012-02-28 22:54:33