What I want to achieve is the following.
When I recibe a request for a HTML, JS or CSS file, return its minified version. I minify when I publish, not dinamically.
Example:
Browser asks por /index.html
Server checks the extensions
Server checks if a index.min.html exists on disk
If exists, server returns index.min.html file, else index.html
All in a single request
I tried read about rewriting and file providers, but I didn't found a standard nor easy way to do this.
What should be the way to do this?
Thanks in advance!
Related
I am creating my whole application with .html extension, to play with the database I am using jQuery Ajax. I have created the project structure like WordPress, for each file I am having a folder and inside that folder I am having an index.html file.
In the above picture, I have created user/equipment/index.html, in this file all the equipment are being shown, now I want that if user clicks on an equipment then the URL should be like 'domain.com/user/equipment/equipment-title' and the file should be called user/equipment/details/index.html
I believe that this can be done with a .htaccess file.
Any solution for the problem would be much appreciated.
Well, you need to store the references in that index file the way you want them to be, request rewriting (wo which you refer as ".htaccess") cannot do that for you. Why you can do with request rewriting, so inside a distributed configuration file (".htaccess") is to the internally rewrite the incoming requests. For that you need a mapping from request URLs to your detail pages. If the mapping the simply the name as to be found in the "equipment" folder (this is unclear from your question), then you indeed can simply implement a rewriting rule.
This would be such an example:
RewriteEngine on
RewriteRule ^/?user/equipment/(.*)/?$ /equipment/$1 [END]
This will deliver the content of the file /equipment/equipment-title when the URL https://example.com/user/equipment/equipment-title gets requested and that file exists.
For this to work the rewriting module has to be enabled inside your http server and, if you want to use a distributed configuration file for this, the interpretation of such files also needs to be enabled for that location inside your http server. Usually the better alternative is to place such rules in the real http server's host configuration, though.
Various webservers allow the configuration of welcome files, so that when an URL points to a directory and the directory contains an index.html file, that file is being served.
Can I configure polymer serve so that it also serves index.html files when a directory URL is requested?
Internally, polymer-cli is based on polyserve, which is based on Express, having middleware abilities that might help. Do I really have to go so deep?
Unfortunatly polymer-cli only passes on to express a set of pre defined arguments. see: https://github.com/Polymer/polymer-cli/blob/c5f8db4c3db39fdb90a089739a5c48961210417a/src/commands/serve.ts#L63
But it looks like the ability to add middleware is in the works https://github.com/Polymer/polyserve/issues/250
So I have this Ember.js project, using node for a back-end. I am trying to add a .htaccess file so i can set exparation headers for my css,js etc. I tried putting it in the root folder of the Ember project but it does not get detected. I have a robots.txt file in the same place and it is detected fine.
I am also using Apache to redirect the domain to work with my node backend. I dont think this should be a problem as the robots.txt file is still detected this way.
Where is the best place to put the .htaccess file or is there an another soloutin to do the same thing that works with Ember?
I'm writing an apache2 module
by default and when viewed in a web browser, the module would only print the first lines of a large file and convert them to HTML.
if the user choose to 'download as...', the whole raw file would be downloaded.
Is it possible to detect this choice on the server side ? (for example is there a specific http header set ?).
note: I would like to avoid any parameter in the GET url (e.g: "http://example.org/file?mode=raw" )
Pierre
added my own answer to close the question: as said #alexeyten there is no difference. I ended by a javascript code the alter the index.html file generated by apache.
I am trying to find a way to make sure browsers dont cache versions of my css files everytime I push a new update.
I was thinking the best way would be to somehow get the file timestamp of the css file on the filesytem and append append it tot he css URL somehow like www.mysite.com/css/style.css?13245645434
Is this possible at all? If not, then any idea how i can make sure the browser gets a new version of the file when it is updated? I dont want to eliminate browser cache all together because if the file hasnt been touched then i would like it to be cached. However, when i push a new update i would like to someone tell the browser that.
I understand i can write server side code to put the style.css?2342343 in but i want to see if its possible through apache at all.
Thanks
everytime I push a new update
How do you push updates? If there is an automated build process you have then that is the right place to rewrite your URLs.
If you wanted to do the rewriting via apache you'd need a module which would parse the html and rewrite the links. That would not be optimal.
Lastly, consider rewriting to /css/42/style.css (where 42 is the current version) because in case you cache your site through a proxy or CDN, query parameters may not work.