0

使用 Silex 时,我定义了一个简单的路由,如下所示:

 $app->get('/hello', function() use ($app, $help){             
    $response = new Response( 
       json_encode( array("message"=>"hello") ), 400 
    );
    return $response; 
 });
  • 与:curl -X GET -i -c cookies.txt http://mysite/web/hello
  • 我得到:{"message":"hello"}

  • 和:curl -X GET -k -i -c cookies.txt https://mysite/web/hello
  • 我得到:HTTP/1.1 404 Not Found

如何根据请求中的安全上下文为 http 和 https 定义相同的路由?

更新1:额外信息

Apache2的配置方式如下:

默认

<VirtualHost *:80>
        ServerName   mysite

        DocumentRoot /var/www/mydev
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/mydev/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride all
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

默认-ssl

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
        ServerName   mysite

        DocumentRoot /var/www/mydev
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/mydev/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ... Using default Apache2 configuration
        SSLEngine on


        #   A self-signed certificate can be ...
        SSLCertificateKeyFile /home/user1/ssl/server.key.insecure
...
</VirtualHost>
</IfModule>
4

0 回答 0