Here's my apache 2.4 virtual host config
<VirtualHost *:80>
DocumentRoot /var/www/fd-pro/app-api/public_html
ServerName subdomain.domain.com.au
ServerAlias subdomain.domain.com.au
<Directory /var/www/fd-pro/app-api/public_html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/subdomain-error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/subdomain-access.log combined
</VirtualHost>
I have enabled rewrite module also.
And there is an htaccess in /var/www/fd-pro/app-api/public_html
saying
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header set Access-Control-Max-Age "1000"
Header set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
But still its not working!
Any clues, please?
Best Answer
You should not use .htaccess if you have access to the main configuration, add your configuration in virtualhost context and it will save you much hassle, but if you insist.
To answer your qwestion: What is missing from that .htaccess you pasted is the directive:
Since loading mod_rewrite is not enough, to "enable" its functionality in your server you must add this directive before you add any others in the context where you want to use it.
To improve your solution:
Still, you do not even need that set of "deprecated" method for mod_rewrite since a single:
in your virtualhost would do exactly the same, without mod_rewrite and without so many directives for one thing.