小编Bri*_*ood的帖子

.htaccess 将 http 重写为 https 导致循环

在运行 varnish 的 apache 2.2 服务器上,我试图将 http -> 重定向到整个 Drupal Commons ( http://commons.acquia.com/ ) 站点的https 。

由于 varnish 缓存了一些重定向(我认为是 R=301,但不是 R=302),我首先让重定向在 :8080 工作,而 varnish 不提供该重定向。

下面的 .htaccess 代码成功地将 http://foo.example.com:8080 重定向到 https://foo.example.com。(适用于 Chrome、FF 和 Safari。)

# RewriteBase /

### Standard Drupal7 .htaccess above here  ###

# SSL REWRITES
RewriteCond %{SERVER_PORT} ^8080$
RewriteRule ^(.*)$ https://foo.example.com/$1 [NC,R=302,L]

### Standard Drupal7 .htaccess below here  ###

# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} …
Run Code Online (Sandbox Code Playgroud)

rewrite http https .htaccess apache-2.2

5
推荐指数
1
解决办法
2585
查看次数

标签 统计

.htaccess ×1

apache-2.2 ×1

http ×1

https ×1

rewrite ×1