tags with hrefs that point to PDF files. ...">

Can I set "HTML" The name of the PDF file served by my Apache web server

I have HTML pages containing <a> tags with hrefs that point to PDF files. My Apache web server serves them just fine, but the name, as shown in the browser history, refers to the file name. I would like to be able to set this header.

Perhaps there is a title that can be set?

I do not want to write a script to work with files, since the server can handle Content-Encoding negotiation (for example, for gzip) and control the flow, none of which I want to recreate.

+4
source share
2 answers

Here is the HTTP header you can set.

Content-Disposition:inline; filename="*File name you want*"; 
+3
source

I suspect the problem is that the client browser keeps the file name in the history, which you cannot fix.

The last thing I checked, the title in the story came from setting the HTML page (not the header), so there shouldn't be an HTTP header field for the header.

I am not an HTTP expert and I don’t know all the fields, but I don’t remember that on any server I’ve ever worked on, there was a parameter that set the page title (only status code, protocol, etc.).

+1
source

Source: https://habr.com/ru/post/1348146/


All Articles