I have a page that I dynamically show my Unix scripts in another folder. I added:
AddType text/plain .sh <-- this is the only thing in .htaccess in the "unix" directory
So I could see the codes, but SOME files are still offered as a download while others go to the correct plain text display.
Here's the site live:
http://snyfarvu.farmingdale.edu/~gerbss/
Unix scripts: guess.sh, add.sh, lock.sh are the ones that are acting up
Thanks for your suggestions
It's working for me in Chrome, Firefox and Safari on Mac OS X. Did you click those links before adding the .htaccess? If so, your browser may be using the cached response which would be missing the content type header.
Try clearing your browser cache and trying again.
Related
I am currently running Magento 2.1.14 and have enable gzip per the Magento documentation as well as the other well visited posts on this site. I have also doubled checked with my hosting provider that Mod_deflate is enabled on the server side.
In addition, I have a copy of my site on my local machine with same htaccess files as what resides on our live server.
On my local machine, simply enabling the apache module and then adding the htaccess code in the main htaccess file of the public_html directory works. All requests on my local site show headers that contain “Content Encoding: gzip”.
However, when live using https on our server, the gzip encoding seems to stop at the pub directory. NO content coming from the pub directory (pub/static and pub/media) shows and gzip encoding. The files on my local machine and live server are the same. According to my hosting provider, gzipped is enabled on their side and they believe that is has to do with one of the htaccess files in my file tree that is stopping the gzip encoding from happening.
I did a small test recommended by our hosting provider as well, and tried to set up an extra directory in the public_html directory on both my local machine and the live server to test if the gzip encoding would work. On my local machine, I can visit the directory and the file in it shows gzip compression, but on my live server, when adding the file to my public_html directory and attempting to visit it through the browser, Magento throws a 404 error!
Does anyone out there have any idea why gzip would not waterfall through my file tree and properly gzip the js, minified js, css and minified css files that are located in the pub folder?
After days of debugging it turns out that on my live server, the RequestHeader for Set-Encoding was being stripped. This was not happening on my Apache setup on my local machine. My web host still has not give me an explanation why this was happening, nor do I know if it has to do with the htaccess file in the pub/static directory, but adding the RequestHeader set below:
<IfModule mod_headers.c>
Header set X-UA-Compatible "IE=edge"
Header set Connection keep-alive
#THE LINE BELOW THIS COMMENT
RequestHeader set Accept-Encoding "gzip, deflate, br"
<FilesMatch "\.(appcache|atom|bbaw|bmp|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
Header unset X-UA-Compatible
</FilesMatch>
to the htaccess file in the root of my magento site fixed the issue with the compression.
If this is a server issue, I would like someone to comment below on what I might bring up with my webhost to address this. Otherwise, I'm going to submit an issue to the Magento github.
Very strange issue,
deflate mode included in .htaccess of pub/static
bat not for all file types,
javascript files not added to setting
so,
just edit pub/static/.htaccess
and edit row with start - AddOutputFilterByType DEFLATE
and add content type -
text/javascript application/javascript application/x-javascript application/json image/svg+xml
now, all static content will with gzip.
Strange, why was missed this,
maybe for other features ?
I have used .htaccess file with below code
AddType application/x-httpd-php .html .htm
it works fine in local but when I upload my files on server it is not working fine.
My all pages have html extension.
You will need to add a mapping to the PHP exe for the html extension.
IIS has a list of extensions and, based on the file extension will choose the server side processor based on this list.
If you right-click on "Web Sites" in IIS and select "Properties", you can change your ISAPI extensions.
Find the htm and html extensions and change the executable to be the same as they are for .php
OK I have a website that serves podcasts in MP3 format. There is a .htaccess that routes requests for MP3 files to a download script, and that is as follows:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule (.*.mp3)$ download.php?file=$1
</IfModule>
The PHP download script is as follows:
$filename = (isset($_REQUEST['file']) ? $_REQUEST['file'] : '');
$filesize = #filesize($filename);
if ($filename == '' || $filesize == 0) exit(0);
header("Content-Type: audio/mpeg");
header("Content-Description: {$filename}");
header("Content-length: {$filesize}");
header("Content-Disposition: attatchment; filename={$filename}");
readfile($filename);
Everything works beautifully on PC, and in most Mac browsers. However, on Safari, Quicktime is intercepting the download. Same thing is happening on iPhone and iPad. Since the target audience is likely to be mostly Apple users, I would like the "Download" button to do just that -- download, not play in the browser with the Quicktime plugin, regardless of device. The "Stream" button can play the file in the browser, but not the "Download" button.
Doing a Right-click (or Cmd+Click) and Save File As... is not acceptable.
Is there any way to do force download across all platforms with PHP, HTTP, HTML, etc. that doesn't require the user to do anything except click the Download button?
You need to set the content-disposition HTTP header when serving the file. By setting this HTTP header it will instruct the browser to provide a prompt which lets the user save or open the file. You can find more information here:
http://support.microsoft.com/kb/260519
You can divide your streams and downloads in two separate folders in combination with the following:
"If you want to force all files in a directory to download, create a .htaccess file in that directory, then paste this in it:
## force all file types to download if they are in this directory:
ForceType application/octet-stream
Don’t stick this in your root level .htaccess file. It will cause all the files on your server to download."
You can read more about this in this conversation:
https://css-tricks.com/snippets/htaccess/force-files-to-download-not-open-in-browser/
I have been trying to force images to download using PHP Headers but there have been multiple problems.
So, instead, how can I use .htaccess so that when I link to an image like:
Download
...instead of opening that file in browser, the file is actually downloaded and saved to the user's computer.
I am already using .htaccess in my project to rewrite URLs if that affects anything.
Put this into your .htaccess
<FilesMatch "\.(?i:jpg|gif|png)$">
Header set Content-Disposition attachment
</FilesMatch>
Make sure you have mod_headers installed and enabled.
I have a very simple .htaccess file set up to redirect a 404 to a php script:
ErrorDocument 404 /404.php
This works as expected in Safari, but does not work in Google Chrome (on a Mac or a PC).
I have also put a 404.htm file to see if the php script was the problem, but had the same results.
Why would Chrome have a different experience over Safari for this? I expected the .htaccess file to be a server-side redirect, so there shouldn't be any browser issues.
(All cache was cleared on all browsers before testing as well)
Chrome displays specific error messages for 404 an such, you'll have to disable it manually in its options:
http://www.google.com/support/chrome/bin/answer.py?answer=95671