【问题标题】:.htaccess - how to redirect https:// to http:// for specific url.htaccess - 如何将 https:// 重定向到 http:// 以获取特定的 url
【发布时间】:2018-06-25 09:08:14
【问题描述】:

这是我当前的 .htaccess 文件。我的项目已经有 https:// 但我想在没有 https 的情况下打开特定的 url。有什么办法可以强制一个特定的 url 访问 http?

<IfModule mod_rewrite.c>
        <IfModule mod_negotiation.c>
            Options -MultiViews
        </IfModule>

        RewriteEngine On

        # Redirect Trailing Slashes If Not A Folder...
        RewriteCond %{HTTPS} off
        RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


        # Handle Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]

        # Handle Authorization Header
        RewriteCond %{HTTP:Authorization} .
        RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    </IfModule>

【问题讨论】:

标签: php laravel .htaccess laravel-5


【解决方案1】:

当然可以:

Options -MultiViews
RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} !/specific-url [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{THE_REQUEST} !/specific-url [NC] 将跳过/specific-url 进行http -&gt; https 重定向。

【讨论】:

  • 假设我不想用https打开的网址是abc.com/demo我应该写RewriteCond %{THE_REQUEST} !/demo [NC]
  • @anubhava 能否以某种方式在数组或列表等单行列中传递多个确切的 URL?
  • 是的,它可以做到,例如RewriteCond %{THE_REQUEST} !/(demo|demo1|demo2) [NC]
  • 我做了但注意到实际上发生了。我不想用 https 打开的 url 仍然用 https 加载
  • 在新浏览器中测试或使用命令行 curl 进行测试。还用最新的 .htaccess 更新问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多