0

I tried following two locations to put my .htaccess

app/wsgi/.htaccess

and app/.openshift/config/.htaccess as suggested here: where to place htaccess file on openshift for wordpress?

neither seems to be correct. I added some junk to .htaccess, the site still runs. I added

Deny from all 

to the top of htaccess file, still the site works fine. So where is the .htaccess file supposed to be?

Community
  • 1
  • 1
Emmet B
  • 5,341
  • 6
  • 34
  • 47
  • What are you actually trying to do? I think the only place where a .htaccess file may be honoured if using Apache under standard OpenShift Python cartridge would be the directory where the static files are kept. That would only affect access to static files and not the actual Flask application itself. – Graham Dumpleton Jun 04 '15 at 06:54
  • @GrahamDumpleton I am trying to leverage browser caching for static files such as css, png, etc. – Emmet B Jun 04 '15 at 07:35

1 Answers1

2

Try reading:

Static files go in 'wsgi/static'. You can then in that directory place a '.htaccess' file and configure anything that the main Apache configuration file allows you to in a .htaccess file.

This only works if you are using Apache to serve up the static files. If you are using a feature of the Python web framework or a WSGI middleware to serve up the static files, you can't do it with the default Apache configuration as there is no way to affecting things for the physical 'wsgi/static' directory.

So where are you currently putting the static files?

Community
  • 1
  • 1
Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
  • I normally put my static files to app/static. now I created a static folder under wsgi (app/wsgi/static), and the website could not find my css files, and it was saying the static directory was blocked. – Emmet B Jun 04 '15 at 08:18
  • It has to be 'wsgi/static' under the project root for OpenShift to find it. Cannot be place down inside any sort of project sub directory. If you have it in 'app/wsgi/static', does that mean you were having the Python application serving up the static files rather than Apache? – Graham Dumpleton Jun 04 '15 at 09:03
  • yes, app/static is the default static folder for Flask. – Emmet B Jun 04 '15 at 11:25
  • So if you shift the files in that to 'wsgi/static' instead then Apache under OpenShift Python cartridge should serve them up instead. They will be available under the '/static' sub URL and that can't be changed, so your original code when using Flask to serve up static files would need to have used that prefix as well. When you have Apache serving up the files then you can try adding the .htaccess file in 'wsgi/static' directory. – Graham Dumpleton Jun 04 '15 at 12:25