Wrong 404 handler for HTML Site type
Following block is not needed
location / {
try_files $uri $uri/ /index.html;
}
It uses homepage for 404. This works good for wordpress but for static site this is not good.
Adding some notes:
I added following on a static site:
error_page 404 = @404;
location @404 {
rewrite .* /search.html?q=$uri redirect;
}
Now 404 URLs redirect to search page and old URL is sent as query string. That way user may not feel much lost.
Can this work for WordPress as well?
I've been looking for a solution like this that didn't require a plugin.
On Wednesday, June 3, 2015, Rahul Bansal [email protected] wrote:
Adding some notes:
I added following on a static site:
error_page 404 = @404; location @404 { rewrite .* /search.html?q=$uri redirect; }Now 404 URLs redirect to search page and old URL is sent as query string. That way user may not feel much lost.
— Reply to this email directly or view it on GitHub https://github.com/rtCamp/easyengine/issues/561#issuecomment-108468443.
Not sure.
We need to play with try_files and 404.
I did play a lot sometime ago but couldn't figure it out.
Hint: fastcgi_intercept_errors may help (did not try it last time)
Thanks Rahul! I did some searching in the WP forums and ran across a thread that has some solutions but it looks like the 404.php and search.php files may need to be altered to assure 404's will still be logged. Also, not sure how to translate the htaccess script to nginx, but that's mentioned as well. Might be a nice plugin for you guys to add to your helpful tools line! :)
https://wordpress.org/support/topic/plugin-redirection-is-turning-a-404-into-a-search-a-stupid-thing-to-do
On Wednesday, June 3, 2015, Rahul Bansal [email protected] wrote:
Not sure.
We need to play with try_files and 404.
I did play a lot sometime ago but couldn't figure it out.
Hint: fastcgi_intercept_errors may help (did not try it last time)
— Reply to this email directly or view it on GitHub https://github.com/rtCamp/easyengine/issues/561#issuecomment-108481918.