Can I send HTTP headers on an FTP URL?

2019-02-21 04:42发布

问题:

Is there any possibility to send HTTP headers on an ftp:// URL? How would I go about it?

What I want is HTTP based crawlers to see an HTML Response (in the headers) while human users see the pure FTP Content.

What would be the smartest way of solving this problem? I thought about user agent specific redirection, however this seems to be against most search engine's guidelines.

What I want is for bots to index an HTTP version of the content, while normal users can get access to the FTP version, all while using a single ftp:// URL.

Is this doable?

回答1:

It's NOT doable.

You cannot redirect ftp:// URL to http:// URL. The FTP protocol has no redirects. FTP protocol does not even know what URL is. Nor does a web browser (acting as an FTP client) send "user agent" or anything similar to the FTP server.

There are also no headers in FTP protocol (but that's just a technicality, comparing to the fact above).

FTP protocol is completely different to HTTP.


You are obviously confused by the web browsers (all of them) presenting an FTP resource the same way as an HTTP resource. But it's just a "game" by the browsers. They are nowhere near similar.

Note that FTP was invented eons before Internet, HTTP, web and URLs.


Though note that you may be able to do it other way around. You should be able to redirect HTTP to FTP.

But I still do not think it's a good idea. If the clients need FTP, they probably want to use a real FTP client, not a web browser. And a real FTP client won't understand HTTP (redirects).