I'm trying to get my redirect to work but am having trouble. The HTTP to HTTPS redirect does work, but trying to make a RESTful API is not. Any ideas would be appreciated. Thank you.
<VirtualHost *:80 *:443>
<Directory /var/www/example.com/public_html>
#Options +FollowSymLinks
Options -Indexes +FollowSymLinks
AllowOverride None
Require all granted
</Directory>
ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog /var/www/example.com/error.log
CustomLog /var/www/example.com/requests.log combined
RewriteEngine On #only turn on once
#force https
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
<Directory "/var/www/example.com/public_html">
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)$ /api/index.php?rquest=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ /api/index.php [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -s
RewriteRule ^(.*)$ /api/index.php [QSA,NC,L]
</IfModule>
</Directory>
</VirtualHost>
Edit: I rewrote the 2nd Directory section to look like this:
<Directory "/var/www/example.com/public_html">
<IfModule mod_rewrite.c>
RewriteEngine On
#force https
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)$ /api/index.php?rquest=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ /api/index.php [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -s
RewriteRule ^(.*)$ /api/index.php [QSA,NC,L]
</IfModule>
</Directory>