I'm trying to optimize my site using Google Analytic's site speed suggestions and one of the suggestions it gave me was to Leverage Browser Caching in my .htaccess file.
After doing some research on .htaccess I found that my site didn't have one. I created my own .htaccess and filled it with the below text:
AllowOverride All
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##
I uploaded it to my site, and now when loading any of the pages on my site I get an error page that says the following:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable
to complete your request.
Please contact the server administrator, [no address given] 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.
Any idea what might be causing this? I'm new to this so any help would be greatly appreciated!
Remove or comment out this line
AllowOverride All
As this directive isn't allowed in htaccess. It is only allowed in Apache config, hence presence of this line is causing internal 500 error.
Related
I am using Apache 2.4 on CentOs to power my website. However, I always get a 403 forbidden error when trying to access the website through my browser. When I consulted the file error_log in the log directory of /etc/httpd, I repeatedly see the error:
AH01630: client denied by server configuration
I have read in the Internet as well as in multiple StackOverflow questions that you can solve this error with Require all granted in the html directory configuration of the httpd.conf file (/etc/httpd/conf/).
I have configurated this directory (through which I am hosting my website) like recommended above (it was already configurated). The error persists, so there must be another problem in the server configuration that denies access to my website. My httpd.conf file is not changed at all, it is the default file that gets downloaded when installing Apache 2.4. Does anybody know why this error occurs? Can somebody explain to me what else can cause this error? I have looked everywhere in the internet for this error (links below) but nothing could help me at this problem.
I have no .htaccess file in my website. Only an index.html file to test it.
Stack Overflow Question: "Apache2: 'AH01630: client denied by server configuration'"
Apache Wiki
Serverfault
I just deleted the whole HTTPD configuration and then reinstalled Apache. I had to enable PHP too by using these lines of code:
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Then Apache worked flawlessly.
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?
I followed this as a solution and my .htaccess now reads:
<DirectoryMatch /mypath/to/my_subdir/(.)*/>
Options +Indexes
</DirectoryMatch>
Yet when I visit my subdir (http://www.example.org/my_sub/) I am getting the following error message:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at webmaster#mydomain.org to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
The .htaccess file noted above is living in /public_html/ directory.
I've been cleaning up my project lately. I have a main .htaccess in the root directory and 6 others. 5 of them ran Options -Indexes which i didn't see anypoint of allowing any Directory viewing so moved that to the main one. so now i only have 2 .htaccess files. the main and one in /system which holds
# Block External Access
deny from all
So i wanted to run that on /system only from within the main. So i deleted the one in /system and added
# Block External Access
<Directory "/system/">
deny from all
</Directory>
to my main .htaccess file leaving 1!
but now i get a
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator, webmaster#localhost 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.
Apache/2.2.17 (Ubuntu) Server at 10.0.1.5 Port 80
The goal is to block reading any files in /system and it's sub directory's but allow viewing of everything else all from one .htaccess file for the whole project. Any ideas on how i can fix this? I did some Google searches but couldn't really come out with anything.
You cannot use the Directory directive in .htaccess. However if you create a .htaccess file in the /system directory and place the following in it, you will get the same result
#place this in /system/.htaccess as you had before
deny from all
You can also use RedirectMatch directive to deny access to a folder.
To deny access to a folder, you can use the following RedirectMatch in htaccess :
RedirectMatch 403 ^/folder/?$
This will forbid an external access to /folder/ eg : http://example.com/folder/ will return a 403 forbidden error.
To deny access to everything inside the folder, You can use this :
RedirectMatch 403 ^/folder/.*$
This will block access to the entire folder eg : http://example.com/folder/anyURI will return a 403 error response to client.
You can use from root directory:
RewriteEngine On
RewriteRule ^(?:system)\b.* /403.html
Or:
RewriteRule ^(?:system)\b.* /403.php # with header('HTTP/1.0 403 Forbidden');
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)$">