我在CentOS上运行了CodeIgniter项目,并成功安装了EV证书。
我不希望在访问/ rss目录时使用SSL。我有这个工作,但我在升级过程中以某种方式打破了它。
这是我的.htaccess文件,我认为是正确的:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# redirect to SSL connection
RewriteCond %{REQUEST_URI} !^/rss/
RewriteCond %{SERVER_PORT} 80
# R=301 sends HTTP Moved Permanently L=Last rule for this request
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
转到该网站后,该网址已正确更改为https://www.site.com 但是访问www.site.com/rss也会改为https。 我不希望它为该目录使用ssl。 我认为.htaccess文件是正确的,所以也许它是CodeIgniter的东西...... 如果有人有想法,我将非常感激。
答案 0 :(得分:4)
可能发生的事情是mod_dir没有按照它之前的顺序进行干预(默认情况下,mod_dir会重定向,如果您访问目录但不包含尾部斜杠,则重定向到相同的URL with 尾随斜杠)。如果您尝试访问http://www.site.com/rss RewriteCond %{REQUEST_URI} !^/rss/
个匹配项(因为请求uri以“/ rss”开头!=“/ rss /”),它会被重写为https://www.site.com/rss。然后mod_dir接管并重定向到“https://www.site.com/rss/”。在升级之前,mod_dir可能首先应用重定向,因此您被重定向到“http://www.site.com/rss/”,然后第一个条件(!^ / rss /)失败,因此您无法获得重写为https://
尝试将第一次重写条件更改为:
RewriteCond %{REQUEST_URI} !^/rss/?$
所以URI就像“/ rss”和“/ rss /”会使匹配失败而不会被重定向到https://