<FileMatch> added in Htaccess causes Internal Server Error 500 - apache

I had font-loading problem.
So I added this code to my root .htaccess:
<FilesMatch "\.(eot|otf|woff|ttf)$">
SetEnvIf Origin
"^http(s)?://(.+\.)?(domain1\.org|domain\.com)$" origin_is=$0
Header set Access-Control-Allow-Origin %{origin_is}e env=origin_is
</FilesMatch>
But the server throws Error 500.
I also have enabled mod_headers, and have checked it with phpinfo() to see if it's loaded or not, and it says it's loaded.
I have restarted the WAMP, but still the problem exists.

Related

Internal server error with Apache 2.4 in .htaccess on WAMP

The Apache 2.4 documentation mentions .htaccess as a valid context for using the <FilesMatch> directive, with, for example, a Require all denied in it.
Ref: https://httpd.apache.org/docs/2.4/en/mod/core.html#filesmatch
Yet, it leads to a 500 Internal Error if I place it in an .htaccess, and no error if I place it in the main configuration file.
However, it seems like it is less the FilesMatch directive that is a problem than the Require all denied, as no errors occurs if I leave the former empty.
Example of the block that I use:
<FilesMatch "[\._](htaccess|passwd|inf|ini|inc|cls)$">
Require all denied
</FilesMatch>
Any idea of how to make it work in the .htaccess file?

Moving from development to production and FA icons are now squares

Development
Production
I've read a ton of other posts, and 99% of them boil down to path issues. But if you look at my site you can see that it is properly loading the icon file:
Request URL:http://www.blackrhinounion.com/wp-content/themes/Centum/font/fontawesome-webfont.woff2?v=4.3.0
Request Method:GET
Status Code:304 Not Modified
So I'm thinking something else is the culprit here?
(Edit) Attempted in .htaccess:
# Allow access from all domains for webfonts.
# Alternatively you could only whitelist your
# subdomains like "subdomain.example.com".
<IfModule mod_headers.c>
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css|css)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
</IfModule>
And it still didn't fix it.
Figured it out.
WP_SITEURL had a www in it, while the WP_HOME didn't. That caused the Cross-Origin issue, removing the www fixed everything.

cakephp setting custom header does not work, htaccess, apache

I am experiencing some odd behaviour.
I have debian 7(on the vmware if it matters) with apache 2.2.22. For my cakephp application I want to set custom header, so I put this in app/webroot/.htaccess file (without removing what already exists of course)
<IfModule mod_headers.c>
Header append X-FRAME-OPTIONS: DENY
</IfModule>
but when I request the page, in firebug net panel it does not show X-FRAME-OPTIONS header. Headers mod is enabled. a2enmod headers outputs Module headers already enabled. Apache is restarted (even OS is rebooted). This cakephp application(copied by 100%) I tested on my vps(again debian 7), and it shows that header just fine. So, first it made me believe there is smth wrong with my local debian, but then I tested this. I created single file index.php in www/some_test folder and put echo "ok". Also created .htaccess with the same content
<IfModule mod_headers.c>
Header append X-FRAME-OPTIONS: DENY
</IfModule>
And the funny part is, I could see in firebug that X-FRAME-OPTIONS header. So, the bottom line with cakephp application, in the server1 custom headers are fine, in server2 - does not show, for simple index.php 'app' in server2 headers are fine again. Can someone help what the problem can be. I need to set custom headers.
Thanks
I am not sure what was the problem, but removing and reinstalling the php solved it
apt-get remove php5*
apt-get install php5
https://superuser.com/questions/673837/php5-ini-file-is-blank/674408#674408

HTTP Error 500 - Apache2 - Aliased Directory

I have this in my httpd.conf . I have no problem accessing index.php and the PHP code works fine inside it, however classes.php -another file I have in the same directory gives me a HTTP Error 500.
Alias /serv /home/will/Dropbox/Business/serv
<Directory /home/will/Dropbox/Business/serv/>
Order allow,deny
Allow from all
</Directory>
The problem was actually an error with the PHP code.
If you are getting this error but are not sure why it is probably because you have a syntax error of some sort. It seems that if display_errors is turned off in php.ini apache will simple return a 500 error. Navigate to /etc/php5/apache2 and find display_errors in php.ini and switch it to "On". Your page should now tell you what sort of PHP error you are getting and will not simply return a 500.

Internal server error after editing .htaccess in CakePHP

I want to disable the browser cache for CSS, images and scripts by adding this code to webroot/.htaccess file:
<FilesMatch "(.)*.(css|js|jpg|jpeg|gif|png)$">
Header set Cache-Control "max-age=1"
</FilesMatch>
This is the error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
When I add a command to every .htaccess file in CakePHP, I receive this error!
Use FilesMatch:
<FilesMatch "\.(css|js|jpg|jpeg|gif|png)$">
Improved (note I removed "jpg"):
<FilesMatch "\.(css|js|jpe?g|gif|png)$">