Bonfire / Codeigniter:可从HTTP访问但不能从HTTPS

时间:2017-10-16 14:28:59

标签: apache .htaccess codeigniter mod-rewrite bonfire

我有一个基于Bonfire / Codeigniter的应用程序,功能齐全,没有任何问题,可通过HTTPS协议访问。

但我有一个名为 App 的文件夹,可以从外部篝火访问,只适用于 HTTP ,如果从 HTTPS 访问它我收到 404错误

Bonfire Root
|_ application
|_ bonfire
|_ public
|  |_ app  <--I can access it only over HTTP, no HTTPS.
|  |_ assets
|  |_ ...
|_ tools
|_ index.php

从HTTP访问app文件夹: enter image description here

从HTTPS访问app文件夹: enter image description here

以下是文件ssl.conf:

## ssl.conf ###
<VirtualHost *:443>
        ServerName developer.mydomain.com
        DocumentRoot /var/www/html/mycompany/bonfire-root/public
        ServerAlias developer.mydomain.com
# Use separate log files for the SSL virtual host; note that LogLevel
    ErrorLog logs/ssl_error_log_dev
    TransferLog logs/ssl_access_log_dev
    LogLevel warn

    #   SSL Engine Switch:
    SSLEngine on

    #   List the protocol versions which clients are allowed to connect with.
    SSLProtocol all -SSLv3
    SSLProxyProtocol all -SSLv3

    #   User agents such as web browsers are not configured for the user's
    SSLHonorCipherOrder on

    #   SSL Cipher Suite:
    #SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM
    #SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
    SSLCipherSuite HIGH:!aNULL:!MD5:!3DES:!CAMELLIA:!AES128

    #   Server Certificate and Keys:
    SSLCertificateFile /etc/letsencrypt/live/***MY-DOMAIN***/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/***MY-DOMAIN***/privkey.pem

 <IfModule mod_rewrite.c>
       RewriteEngine On

       # Enforce SSL https://www.
       RewriteCond %{HTTPS} !=on
       RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteCond $1 !^(app\.php|assets|editor|css|js|scripts|templates|images|img|media|xml|user_guide|robots\.txt|favicon\.ico)
       RewriteCond $1 !\.(css|js|jpe?g|gif|png|tiff|ttf|otf|woff|svg|mp3|mp4)$
       RewriteRule ^(.*)$ /index.php/$1 [L]

    </IfModule>

以下是httpd.conf文件:

    ## httpd.conf ###
<VirtualHost *:80>
    ServerName developer.mydomain.com
    DocumentRoot /var/www/html/mycompany/bonfire-root/public
    ServerAlias developer.mydomain.com

   <Directory "/var/www/html/mycompany/developer">
       Options Indexes FollowSymLinks MultiViews
       Options +FollowSymlinks -Indexes
       AllowOverride All
       Require all granted
       Options FollowSymLinks
       AllowOverride All
       Order deny,allow
       Allow from all
    </Directory>
</VirtualHost>

以下是文件.htaccess:

## HTACCESS ##
<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine On

  RewriteCond %{REQUEST_URI} ^bonfire/codeigniter.*
  RewriteRule ^(.*)$ /index.php?/$1 [L]


</IfModule>

<IfModule mod_rewrite.c>
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
</IfModule>

# Deny robots
<IfModule mod_rewrite.c>
    RewriteCond %{HTTP_USER_AGENT} (googlebot|bingbot|Baiduspider|HTTrack) [NC]
    RewriteRule .* - [R=403,L]
</IfModule>


# 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

<IfModule mod_rewrite.c>
    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>

我已经尝试过很多来自otrhers的选项:

  

.htaccess mod_rewrite - how to exclude directory from rewrite rule

     

htaccess codeigniter mod-rewrite, rewritecond to ignore subdirectory within main app directory

我对这种配置的了解非常薄弱。也许有人可以轻松帮忙:D

1 个答案:

答案 0 :(得分:0)

我可以看到的主要区别是ssl.conf中缺少DIRECTORY块。尝试从httpd.conf复制它,或将其移到VirtualHost外部。