相关疑难解决方法(0)

开发,分期和生产之间的.htaccess

我正在开发一个使用url重写的应用程序,并且具有特定的.htaccess配置.在使用应用程序时,我有三个方面:

  1. 在我的本地机器上开发(localhost)
  2. 暂存(staging.mydomain.com)
  3. 制作(www.mydomain.com)

我不断推动新的升级到登台和生产环境,每次我覆盖现有的源代码,我都要改变.htaccess文件.有没有办法让.htaccess通用到目录或让它自动检测它的环境?

我当前的.htaccess文件如下.我只是取消评论不同环境之间的部分,但很想停止这样做......

# Development

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ /app/index.php?request=$1 [L,QSA]

# Staging

# RewriteEngine on
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteCond %{REQUEST_URI} !=/favicon.ico
# RewriteRule ^(.*)$ /html/app/index.php?request=$1 [L,QSA]

# Production

# RewriteEngine on
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteCond %{REQUEST_URI} !=/favicon.ico
# RewriteRule ^(.*)$ /index.php?request=$1 [L,QSA]
Run Code Online (Sandbox Code Playgroud)

提前致谢!

php .htaccess development-environment

14
推荐指数
2
解决办法
8398
查看次数

密码保护rails登台环境

我正在努力找出保护我的临时环境的最佳方法.目前我在同一台服务器上运行暂存和生产.

我能想到的两个选择是:

使用rails摘要身份验证

我可以把这样的东西放在application_controller.rb中

# Password protection for staging environment
if RAILS_ENV == 'staging'
  before_filter :authenticate_for_staging
end

def authenticate_for_staging
  success = authenticate_or_request_with_http_digest("Staging") do |username|
    if username == "staging"
      "staging_password"
    end
  end
  unless success
    request_http_digest_authentication("Admin", "Authentication failed")
  end
end
Run Code Online (Sandbox Code Playgroud)

这是从Ryan Daigle的博客中扯下来.我正在运行最新的Rails 2.3,所以我应该摆脱他们对此的安全问题.

使用Web服务器身份验证

我也可以使用.htaccess或apache权限实现这一点,但是它使我的服务器配置稍微复杂一些(我使用Chef,并且需要不同的apache配置用于登台/生产).


现在我有第一个实施和工作,你看到它的问题吗?我错过了一些明显的事吗?提前致谢!

authentication ruby-on-rails staging

10
推荐指数
2
解决办法
4271
查看次数