开发者

FilesMatch results in Internal Server Error

开发者 https://www.devze.com 2023-03-15 18:11 出处:网络
I added the code below to my .htaccess file to enable caching files for 3 days. After that my website wasn\'t available anymore and I got a message displayed that told me it\'s an Internal Server Erro

I added the code below to my .htaccess file to enable caching files for 3 days. After that my website wasn't available anymore and I got a message displayed that told me it's an Internal Server Error

The code:

 # 3 DAYS 
    <FilesMatch "\.(html|css|js|gif|jpg|jpeg|png|ico|swf)$"> Header set Cache-Control "max-age=259200, proxy-revalidate" </FilesMatch>

The message:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server admin开发者_JAVA技巧istrator, webmaster@exampple.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

What is wrong with the FilesMatch or what else could cause the Internal Server Error? Thanks


I had this issue a while ago, You can solve it by typing "sudo a2enmod headers" in the command line


this is another solution http://diogomelo.net/node/24

To enable this module, log in as root, and create a symbolic link from mods-available/headers.load to mods-enabled. After that, reload apache and it's done. To do so, I've used this commands.

su -
cd /etc/apache2/mods-enabled/
ln -s ../mods-available/headers.load headers.load
sh /etc/init.d/apache2 force-reload

After that procedure the issue is solved.


It has to be on multiple lines, not all in a single line. This one works fine for me:

<FilesMatch "\.(html|css|js|gif|jpg|jpeg|png|ico|swf)$">
    Header set Cache-Control "max-age=259200, proxy-revalidate"
</FilesMatch>   


This is another possible solution, after applying multiple lines do this simple possible solution.

Problem:

You may have copied and pasted the htaccess instructions directly from a sample code on a website or a slide presentation or somewhere else which creates a problem with the text encoding format.

Solution:

Copy the code again but this time paste it on a simple notepad or text editor and then, copy and paste it again into the ataccess file. This will remove any encoding problem.


Another problem you can have which returns error 500 it's you don't have enabled the AllowOverride directive correctly on the Apache conf file.

Example:

<VirtualHost *:80>
        ServerName yoursitename
        DocumentRoot /var/www/html/site
        <Directory /var/www/html/site>
                Options -Indexes +FollowSymLinks +MultiViews
                Require all granted
                AllowOverride None
        </Directory>

        ErrorLog /var/log/apache2/error_site.log

On that sample there's one AllowOverride none which blocks all .htaccess modifications you can do.

You can remove that AllowOverride None or modify it allowing only the directives do you need. On the example you placed with AllowOverride FileInfo will be ok.

More info about the AllowOverride directive here: https://httpd.apache.org/docs/2.4/es/mod/core.html#allowoverride

0

精彩评论

暂无评论...
验证码 换一张
取 消