When using Silex, I define a simple route like this:
$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"}
But
curl -X GET -k -i -c cookies.txt https://mysite/web/hello
HTTP/1.1 404 Not Found
How can I define the same route for both, http and https, based on the security context in the request ?
UPDATE1: EXTRA INFORMATION
Apache2 is configured in the following way:
default
<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>
default-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>