简体   繁体   English

页面URL与.pdf被识别为fie

[英]Page Url with .pdf to be recognized as fie

I am running college website for over year now. 我现在正在运行大学网站一年多了。 As i main person for documents on website i tried in the past to improve some things. 作为我在网站上的文件的主要人物我过去尝试过改进一些东西。

In our platform we have integrated Google Search(with filetype:pdf set)for browsing thought the docs. 在我们的平台中,我们集成了Google搜索(带文件类型:pdf集),用于浏览文档。

Our college has over 100 computers, and many of them has problem with opening PDF files. 我们学院有100多台电脑,其中很多都有打开PDF文件的问题。

Old links were like this: college.com/Handbook_for.pdf which basically load pdf file. 旧的链接是这样的:college.com/Handbook_for.pdf,基本上加载pdf文件。

I have changed with .htaccess, if link is with .pdf to open it in the webpage as pdf preview in one div and it works on all comps. 我已经更改了.htaccess,如果链接是.pdf,则在网页中将其作为pdf预览在一个div中打开,它适用于所有comps。

BUT

Our search internal search (Google) now doesn't recognize it as PDF and it wont show in the search results. 我们的搜索内部搜索(Google)现在无法识别为PDF,也不会在搜索结果中显示。

This is how google recognize PDF file 这是谷歌识别PDF文件的方式

While trying to fix this, i accidentally found this website (spammy one): Which tricks Google to think that his page is PDF file. 在试图解决这个问题时,我偶然发现了这个网站(垃圾邮件):谷歌认为他的网页是PDF文件。 Google recognize the PDF, even if it's not Google会识别PDF,即使不是

So i think i should do something like that. 所以我想我应该做那样的事情。

I have tried with header("Content-type:application/pdf"); 我试过用header("Content-type:application/pdf"); but it loads the file again. 但它再次加载文件。

Does anyone knows how to "simulate" pdf? 有谁知道如何“模拟”pdf?

If the primary concern is Google, due to using their search engine, this might be fairly easy. 如果主要关注的是Google,由于使用了他们的搜索引擎,这可能相当容易。 Expose the file to the googlebot as an actual PDF, otherwise display it in your embedded DIV. 将文件作为实际PDF展示到googlebot ,否则将其显示在嵌入式DIV中。

if(strstr(strtolower($_SERVER['HTTP_USER_AGENT']), "googlebot")) {
    // Return actual PDF (with appropriate content headers)
} else {
    // Show in div
}

In this way, when it indexes, it will see it as a PDF, but a human opening the page will instead get your embedded version. 通过这种方式,当它进行索引时,它会将其视为PDF,但打开页面的人将改为获得嵌入式版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM