I'm getting the following error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
If you think this is a server error, please contact the webmaster.
Error 500
184.82.228.38
Mon Jan 9 02:48:12 2012
Apache/2.2.21 (Unix) DAV/2 mod_ssl/2.2.21 OpenSSL/1.0.0c PHP/5.3.8 mod_apreq2-20090110/2.7.1 mod_perl/2.0.5 Perl/v5.10.1
Im running a XAMPP server
here is my htaccess file, i don't understand what the problem is.
AuthType Basic
AuthName "Members Area"
AuthUserFile /opt/lampp/htdocs/.htpasswd
Require valid-user
<FilesMatch "(async-upload\.php|wp-cron\.php|xmlrpc\.php)$">
Satisfy Any
Order allow,deny
Allow from all
Deny from none
</FilesMatch>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /members/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /members/index.php [L]
</IfModule>
# END WordPress
I got the same error before and the problem is the location path of the .htpasswd. Make sure you have set the correct path for that file.
I got the same error. It was due to incorrect path of .htpassswd file.
To know current directory path you can use following
echo dirname(__FILE__);
Try to copy your .htaccess and other files to some Internet webhosting and see, if the problem exists there. If not, then you'll be sure that this is purely XAMPP problem. I heard many times that it works really purely about .htaccess run locally.
For example, I don't have working autorization using .htaccess locally, because right after I provide correct login and password I see exactly the same error message as you mentioned. As for me, I'm more than sure that this problem is purely related to incorrect interpretation of .htaccess done by XAMPP (as everything works like a charm on production server), not by some mistakes in .htaccess contents.
I wasted (too) many hours on finding solution and left it. For right now, if I'm developing locally, I rename ".htaccess" to "htaccess", so it is ignored by XAMPP (Apache on-board of it) and re-enable it only when deploing files to production server. This approach maybe isn't to professional, but it saved me a lot of time and stress! :]
On the other hand, if your hosting also fail with the same symptoms, then you'll know, that this is not XAMPP releated problem and you have something wrong with your syntax.
Take a look here for a similar problem reported on StackOverflow.com, where (as I think) the cause is the same as in your issue.
Make sure that your script have the shebang line has the correct path.
Like,
Xamppinstalleddrive:\xampp\perl\bin\perl.exe
I know that this post is old as a mole, but it helped me find my answer still. So I thought, that I would share my solution anyhow.
My problem was, that I had a .htaccess-file in the htdocs-folder. When I moved/renamed it, then it worked.
My .htaccess-file looked like this:
Header add "disablevcache" "true"
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteCond %{HTTP_HOST} !^www.COMPANYNAME.dk$ [NC]
RewriteRule ^(.*)$ http://www.COMPANYNAME.dk/$1 [R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /404.php [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.COMPANYNAME.dk/$1 [R=301,L]
ErrorDocument 404 /404.php
ExpiresActive On
ExpiresDefault "access plus 7200 seconds"
Header unset ETag
FileETag None
<ifmodule mod_deflate.c>
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
Header append Vary User-Agent env=!dont-vary
</ifmodule>
Delete the .htaccess file and let wordpress create a new one for you[This is if you are running a wordpress site].
Things will be up and running.I had the same issue and got it sorted
I know this is old but this worked for me. How to use htpasswd to create protected directories XAMPP / apache
Essentially, you need to put the OS dir of the htpasswrd file (which is outside htdocs for security reasons). Apache can read your file system, you just have to tell it where the file is.
Disabling htaccess solved the problem for me just now. (Thanks community.) However, rather than subtly deleting the ".", I changed the file name to ".htaccess.disabled".
It achieves the same thing, but it's much easier to spot if I forget to re-enable it later. (I think all of us here can think of a time when hours were wasted because of a missing punctuation mark.)
I solved after just disabling a module:
sudo a2enmod -d deflate
Killing apache and restarting the apache service.
Maybe disabling recent enabled modules solve your problem.
Related
I have Apache 2.2.15 configured on the test bed server to serve .webp in lieu of .jpg and .png if available. This works successfully. However, the same configuration does not seem to work on the outward-facing server running Apache 2.4.51.
These are the applicable lines from /etc/httpd/conf/httpd.conf:
<IfModule mime_module>
...
AddType image/webp .webp
...
</IfModule>
<IfModule rewrite_module>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} Chrome [OR]
RewriteCond %{HTTP_USER_AGENT} Edg [OR]
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{DOCUMENT_ROOT}/$1\.webp -f
RewriteRule (.+)\.(?:jpe?g|png)$ $1.webp [NC,T=image/webp,E=webp,L]
<IfModule headers_module>
<FilesMatch "(?i)\.(jpe?g|png)$">
Header append Vary Accept env=REDIRECT_webp
</FilesMatch>
</IfModule>
The only difference between the two configuration files is a) use of the module names (so as to be consistent with the rest of the configuration files) versus the source-file name, and b) the AddType for image/webp is inside the IfModule mime_module block.
I have checked ( httpd -M ) that mod_mime, mod_rewrite and mod_headers.so are all loaded so that isn't the issue (?). Tested with both Chrome and Edge as clients. Verified that the webp images did get there with release make via find(1). but...
Environmentally, the inward facing test bed serves via http, the outward facing production serves via https, but for the life of me I dont know how that would have any affect???
Anyway, I would appreciate a new set of eyeballs on this. [On the test bed, this knocked off about 40% of the page load, so its a rather big deal .]
Let me start by saying that my knowledge of Apache is almost none, so I apologize if I am not using the correct terminology.
I have a website written in Vue, and the routing is taken care by Vue Router. In their documentation, they specify that in order for the router to work correctly, you have to put this in the .htaccess file of your website:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
From what I have been able to understand, all requests are sent back to the index.html file which will take care of loading the correct component based on the path.
My goal is to now allow my website to have a path (let's say /documents) which is not picked up by Vue, but instead shows the contents of the directory and allows you to both navigate and download the contents (Like this).
I have tried a few ways, but they all return a 403 or 500 (possibly due to a mistake in my config). I understand that I need to add a RewriteRule but all of those that I tried return weird errors.
Thanks in advance
You can have multiple rewrite rules based on what the RewriteBase is . In your current set, the rule is applying to the root of the host.
You can add another rule with RewriteBase /documents/. More info: What does RewriteBase do and how to use it?
I recommend reading the docs: https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html
The RewriteCond directive defines a rule condition.
So here a dirty explanation:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
So your RewriteConds says that if the given path/url isn't a file (!-f) and not a directory (!-d) then the next rewrite rule (RewriteRule . /index.html [L]) takes action.
RewriteRule . /index.html [L]
"." is a wildcard, so all urls will be redirect to index.html.
The [L] flags stops the execution (https://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_l)
The RewriteRule ^index\.html$ - [L] stops the execution if the url is index.html.
So, your rewrite rule fulfill your requirements and seems correct.
When you get a 403 you maybe need to add Options +Indexes to your config or htaccess.
In the end, after looking through the docs, I was not able to understand how to set it up. I found this page, and using option #2 I was able to get the directory to at least show up.
I then added the auth to the folder through the .htaccess file and added the .htpasswd file with the username/password combo
TLDR
Create the folder in the location you want. In my case it was in httpdocs/documents
Create a .htaccess file where you put the following contents:
# Omit this section if you do not need the auth
AuthType Basic
AuthName "restricted area"
AuthUserFile /path/to/your/.htpasswd
require valid-user
Order allow,deny
Allow from all
Options +Indexes
Create the .htpasswd file in the location you specified above. To generate the username/password combo I used this
Any corrections are welcome!
I recently migrated a cakePHP app to another debian version but getting the above error. The apache version is 2.4 and below is what i have in the htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
On the browser it displays the following error;
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at sysad#sysad.com 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.
When I check, the apache logs I get the following
htaccess: FilterProvider takes three arguments, filter-name provider-name match-expression,
Its fixed, replaced the FilterPovider mod_deflate.c with the following below
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpg|png|ico|zip|gz|mp4|flv)$ no-gzip
</IfModule>
I know there are a million of questions about this, but I've tried the solutions in other questions and haven't got it to work in my case. I'm trying to redirect everything to index.php:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
This works in my local environment, but in my staging environment it fails and I get a 404 error. I've checked that mod_rewrite is enabled with phpinfo(). I've tried changing a few things like using ^(.*)$ instead of ^ and using /index.php instead of index.php
What else could be the problem?
Figured it out. It was a problem with the configuration of apache. Whoever set it up for the site I'm working on did it like this in the site's .conf file:
<Directory "/data/path/to/directory">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
# and a bunch of rewrite rules...
</Directory>
The AllowOverride None prohibits the use of .htaccess. In our local and development environments, the directory structure is different, so this code doesn't even get applied. That's why the .htaccess was working.
To solve the problem I'll either have to change the line mentioned above to AllowOverride All or add another configuration for the website I'm working on like the one above that does what I wanted to do with .htaccess.
Problems like this shouldn't come up for anyone if their environments are configured appropriately, but if anyone does run into a similar situation, check the configuration of the site in apache!
I have a strange problem where I have two separate urls pointing to the same Rails application
staging.abcxyz.com
staging.abcttt.com
My setup runs apache with passenger. The important thing to note here is that both urls point to the same Rails application in the Document Root directory and are just served by a different urls internally.
Problem
When i try to access staging.abcxyz.com it works and the application is rendered and everything works as expected.
When i try to access staging.abcttt.com apache returns a 403 forbidden.
Apache Config
This is apache configuration of the url that doesn't work for me. Its exactly the same as the one that works expect for changes in the urls.
<VirtualHost *:80>
ServerName staging.abcttt.com
ServerAlias www.staging.abcttt.com
DocumentRoot /srv/abcxyz/current/public/
<Directory /srv/abcxyz/current/public/>
Order allow,deny
Allow from all
Options FollowSymLinks
AllowOverride None
</Directory>
RewriteEngine on
RewriteRule ^/$ /s/home [P]
RailsAutoDetect On
RackEnv staging
RailsEnv staging
RailsSpawnMethod smart
## PassengerAppGroupName
#
# By default, Passenger groups applcations by the the path they are served out of,
# ie /srv/yourapp/current.
#
# At times, it may be useful be serving the same app from multiple vhosts, but have
# them be have different workers. For example, you may have a /ping URL that needs to
# respond quickly, without being affected by the rest of the app. In this case, you can:
#
# * create a new vhost pointing at the same app
# * set PassengerAppGroupName to ping
# * configure a proxy to forward /ping to the new vhost
PassengerAppGroupName abcxyz
# Deflate
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript application/javascript application/json
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
RequestHeader set X-Request-Start "%t"
RewriteEngine On
# Check for maintenance file and redirect all requests
ErrorDocument 503 /system/maintenance.html
RewriteCond %{REQUEST_URI} !\.(css|jpg|png|gif)$
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [R=503,L]
# Rewrite index to check for static
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}/index.html -f
RewriteRule ^/?$ /index.html [QSA,L]
# Rewrite to check for Rails non-html cached pages (i.e. xml, json, atom, etc)
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f
RewriteRule ^(.*)$ $1 [QSA,L]
# Rewrite to check for Rails cached html page
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.html -f
RewriteRule ^(.*)$ $1.html [QSA,L]
</VirtualHost>
Questions
I don't understand why this would be a permissions issue because staging.abcxyz.com can already access the folder. Am i missing something here since both are served from the same directory
Could it be something to do the with the PassengerAppGroupName - but i'm not particularly concerned about having a separate worker send respond to a particular request
I'd really appreciate any help on this. Thanks.
Update
A thing that i notice is if I use the R [redirect] flag instead of the P [proxy] the application works and redirects to the right url but i want to be an internal redirect which does not reflect on the browser.