How to add try_files to location blocks?
strarsis opened this issue · comments
Concerning https://github.com/h5bp/server-configs-nginx/blob/master/doc/common-problems.md#define-error_page-in-each-location-block each location block requires a error_page 404 = /index.php;
.
What is the best way to add this line to the location blocks?
- Fork this repo, branch it and modify the configuration files, tracking and pulling new changes?
- Search + replace in script/SCM (Ansible) to add this line?
- Some kind of conditional in nginx config that passes when a variable is set ($error_page_static)?
- Commented out error_page field that can be commented in when copying the files, similar to 2nd point.
Sounds like you're really asking "how to use this repo"?
A clone of this repo is a functional start point - from there you're free to do whatever you want. Of the options you put forward this:
Fork this repo, branch it and modify the configuration files, tracking and pulling new changes?
Is effectively what I do.
Re the problem that brought you here - I suggest using a 404 front controller - it's much less intrusive and matches how wordpress (or almost any cms) actually works.
I forgot to say: could you please propose an edit to https://github.com/h5bp/server-configs-nginx/blob/master/doc/usage.md#using-directly that would have satisfied your question?
@AD7six: Thank you for your response.
Using a 404 front controller indeed solves the issue.
In WordPress there is one exception though, the [...]/wp/
, [...]/wp-admin/
, [...]/wp-content/
, [...]/wp-includes/
, /plugins/
and other custom directories created and used by some WordPress plugins.
These contain individual PHP files that have to be executable by their own path
which a 404 front controller wouldn't allow.
For most of the public facing site the 404 front controller approach would indeed work well but
not for these extra individual PHP files.