Search code examples
javascriptjquery.htaccessurl-rewritingfile-type

JavaScript: Can I get file extensions even if they are hidden via htaccess


As the title states. I am looking to get the extension of the file, even if it is hidden via htaccess, for example:

.../whatever/index

Imagine it was a php file, is it possible to know that and extract it via JavaScript or jQuery?

Thanks in advance, can't find it anywhere. All I can find is people trying to actually hide the extension.


Solution

  • To achieve this you need some sever-side coding where you can request which file is behind the given path, so when you pass "/whatever/index" you server should returns 'whatever.php' and from that information you could extract the file extension.

    Javascript itself doesn't know anything about what/how things are organized on the backend