需要不同的.htaccess从Git的回购协议分期和直播现场 [英] Need different .htaccess for staging and live site from Git repo

查看:151
本文介绍了需要不同的.htaccess从Git的回购协议分期和直播现场的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的情况:

有一个Git回购协议,这是跟踪网站的文件,包括的.htaccess 的根。 Git的回购被检出到一个临时网站,并到生产现场。

There is a Git repo, which is tracking website files, including the .htaccess at root. The Git repo is checked out to a staging site and to a production site.

的问题:的临时网站必须与密码(通过htpasswd的身份验证)进行保护。这改变了的.htaccess 文件中。现在犯或临时环境推动机构的的.htaccess 文件(这使得密码保护的根目录下)被检查出的Live网站为好,使现场网站索要密码,以及。

The problem: The staging site has to be protected with password (through htpasswd authentication). This changes .htaccess file as well. Now committing or pushing from staging environment means the .htaccess file (which enables password-protection for root directory) is checked-out to the live website as well, making the live website ask for password as well.

现在我怎么做呢?我应该停止跟踪的.htaccess ?我应该覆盖的.htaccess 通过后收到钩(可能吗?怎么样?)?是否有保护目录,而无需修改任何其他方式的.htaccess ?任何其他解决办法?

Now how shall I go about it? Should I stop tracking .htaccess? Should I overwrite .htaccess through post-receive hook (possible? how?)? Is there any other way to protect a directory without modifying .htaccess? Any other solution?

推荐答案

我会选择为不跟踪 的.htaccess 本身。

可能的选项:

  1. 跟踪的.htaccess-PROD 的.htaccess级(如果有更多的差异比较有用,喜欢各种配置设置,密码等,如果是只有一条线,那么也许它不是最好的选择)。然后,当你更新的东西,你必须做在这两个文件,​​同时你必须记得的.htaccess 在两种环境中的文件复制手动发生变化时。

  1. Track .htaccess-prod and .htaccess-stage (more useful if there are more differences, like various config settings, passwords etc., if it's only one line, then perhaps it's not the best option). Then whenever you update something, you must do it in both files, also you'll have to remember copy the files in two environments as .htaccess manually when they change.

商店只有一个文件的.htaccess,比如,在这两种分期和生活区(看的后结账的并增加挂钩/或后合并的可能[1]),将在他们两人,复制的.htaccess,比如作为本地的.htaccess 只要有一个变化,另外,附加在分级密码保护的线路。

Store only one file .htaccess-example, add hooks in both staging and live areas (look at post-checkout and/or post-merge probably [1]) that will, in both of them, copy .htaccess-example as a local .htaccess whenever there was a change, and additionally, append a line with password protection in staging.

[1]没有用他们自己呢,所以我有点糊涂了看的文档。关于后收到的,据我了解,它是在一个远程回购执行推到它的时候,而不是在工作副本时,你拉。

[1] haven't used them myself yet, so I'm a bit confused looking at the documentation. Regarding post-receive, as far as I understand, it is executed on a remote repo when pushing to it, not in the working copy when you pull.

这篇关于需要不同的.htaccess从Git的回购协议分期和直播现场的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆