easyengine icon indicating copy to clipboard operation
easyengine copied to clipboard

Wrong 404 handler for HTML Site type

Open rahul286 opened this issue 11 years ago • 4 comments

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.

rahul286 avatar Jun 03 '15 13:06 rahul286

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.

rahul286 avatar Jun 03 '15 14:06 rahul286

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.

MattyLB avatar Jun 03 '15 15:06 MattyLB

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)

rahul286 avatar Jun 03 '15 15:06 rahul286

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.

MattyLB avatar Jun 03 '15 16:06 MattyLB