【问题标题】:.htaccess - redirect http to https exclude specific url.htaccess - 将 http 重定向到 https 排除特定的 url
【发布时间】:2016-06-09 08:26:23
【问题描述】:

如何将http重定向到https排除特定的url?

http://www.example.com/* => https://www.example.com/*
http://www.example.com/nonssl/* => http://www.example.com/nonssl/*

所以我按照以下方式制作 .htaccess 文件:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/nonssl/
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

但是当我转到http://www.example.com/nonssl/testfunc 时,它转到https://www.example.com/index.php/nonssl/testfunc

提前致谢。

【问题讨论】:

  • /nossl 是一个存在的目录吗?
  • 不,我使用 codeigniter 制作了这个网站。这是一个控制器名称。

标签: apache .htaccess http https


【解决方案1】:

对于这个问题,我没有找到正确的方法,只是描述了所有从http重定向到https的服务。

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/$ [OR]
RewriteCond %{REQUEST_URI} ^/test [OR]
RewriteCond %{REQUEST_URI} ^/test1 [OR]
RewriteCond %{REQUEST_URI} ^/test2
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|css|fonts|js|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]

我知道它只是不推荐的方式。如果谁能解决这个问题,请联系我。 谢谢。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-25
    • 2012-11-02
    相关资源
    最近更新 更多