404 hendler AO + 404 redirect homepage plugin
-
Hey, how are you 🙂
I missed you hahahaSo actually, I do not experience any issue but want to ask something.
My sites have this plugin:
https://es.ww.wp.xz.cn/plugins/all-404-redirect-to-homepage/Now when you go inside the file:
/wp-content/autoptimize_404_handler.phpYou note inside the handler, to put “error_document” in
the .htacsses for the AO 404 Hendler.The 404 plugin i showed you do it for
me already, and this looks like they fit each other.but the 404 plugin redirect to the homepage everything and any page and any URL.
my suspicious, maybe the handler not work? or actually, conflict?
You can get inside my website everything is already ON.Another thing is if i need to bypass the handler from Nginx Dynamic caching?
(I See you noted is HTML caching and must configure in a server level)Not sure if have a problem, I only need good advice 🙂
Can be is work fine and i am crazy.Regards,
Nadav Levi Yahel
Locksmith Unit-
This topic was modified 5 years, 3 months ago by
Nadav Levi.
The page I need help with: [log in to see the link]
-
This topic was modified 5 years, 3 months ago by
-
It indeed does not work Nadav;
this is a working autoptimized file https://locksmithunit.com/wp-content/cache/autoptimize/autoptimize_951ad809080497cebc8eff1fe7c7b59c.php
if you change one letter in the hash like this:
https://locksmithunit.com/wp-content/cache/autoptimize/autoptimize_851ad809080497cebc8eff1fe7c7b59c.phpyou’ll see you’re indeed redirected to the homepage so that 404 plugin cannot be used together with AO’s 404 handler. additionally “404 handler” only works if “serve as static files” if on, which you don’t have either.
frank
Ok, so i will of the option 404 in autoptimize and delete the handler.
Thank you, Frank 🙂
Appreciate this.you’re welcome Nadav 🙂
Frank, i hope you didn’t close this topic.
i tried now to reactive the 404 ao Hendler and off the plugin.
i server static files.but I see in the handler you said:
* will have a “Errordocument:” directive to automatically do this.
in the htacsses.
no, i have inside the htacsses:
#ErrorDocument 404 /index.php?error=404to activate that?
or you have another ErrorDocument i need to put?the site i do the test is:
locksmithunit.catplease if you can help me with that maybe i will use the hendler.
and about Nginx. i need to by pass the PHP AO hendler?-
This reply was modified 5 years, 2 months ago by
Nadav Levi.
well, for the 404 handler to work you’ll have to first and foremost re-enable “serve as static files” Nadav.
Additionally:
* check if 404’s are handled by WordPress (nice error-page) or not. if yes, you have nothing more to do
* if 404’s are not handled by WordPress you’ll have to configure the webserver to redirect 404’s to the PHP-script. if nginx there is example configuration code in the AO FAQ in the question/ response about the 404-handler.frank
I try to do it with Nginx is a little problem to use it in Nginx.
but i can do it from apache.
Now in the FAQ you send, they say the handler adds an Error_document to htacsses.
but nothing is not added.if you can give me the error_document for apache.
let’s see if it will work for us.I did the static file option in auto optimize:
locksmithuni.catLet’s see if apache will do the job for us.
I did nginx now, i dont have anything inside the htacsses.
but i afraid is not work properly, if you can check it, tell me if is work properly:
locksmithunit.catthis from Nginx with the instruction you send me
the errordocument handler _should_ be added to wp-content/cache/autoptimize/.htaccess when you activate the 404 option. you might have to clear AO’s cache?
yes, it works 🙂
existing JS-file: https://locksmithunit.cat/wp-content/cache/autoptimize/js/autoptimize_951ad809080497cebc8eff1fe7c7b59c.js
and non existing JS-file: https://locksmithunit.cat/wp-content/cache/autoptimize/js/autoptimize_851ad809080497cebc8eff1fe7c7b59c.js will redirect to https://locksmithunit.cat/wp-content/cache/autoptimize/js/autoptimize_fallback.js
Ok, think i got it.
so you said is working.
the only dilemma i have is where to put the Nginx block ( i have already one block of css/js for all the folder himself. so need to add it without hurt the other one )i know you not specialized in NGINX but I need you to check it for me just in case i not make
a mistake… 🙁so in your FAQ:
location ~* /wp-content/cache/autoptimize/.*\.(js|css)$ {
try_files $uri $uri/ /wp-content/autoptimize_404_handler.php;
}Now I have one like this:
location / { try_files $uri $uri/ @backend; } location @backend { include proxy_params_common; # === MICRO CACHING === # Comment the following line to disable 1 second micro-caching for dynamic HTML content include proxy_params_dynamic; } # Enable low duration browser cache for static data files (TTL is 1 min) location ~* \.(?:csv|json|xml|rss|atom)$ { include proxy_params_common; include proxy_params_static; expires 1m; } # Enable browser cache for CSS / JS (TTL is 30 days) location ~* \.(?:css|js)$ { include proxy_params_common; include proxy_params_static; expires 365d; } # Enable browser cache for images (TTL is 60 days) location ~* \.(?:ico|jpg|jpeg|gif|png|webp|mp3|mp4)$ { include proxy_params_common; include proxy_params_static; expires 365d; } # Enable browser cache for fonts & fix @font-face cross-domain restriction (TTL is 60 days) location ~* \.(eot|ttf|otf|woff|woff2|svg|svgz)$ { include proxy_params_common; include proxy_params_static; expires 365d; } # Prevent logging of favicon and robot request errors location = /favicon.ico { include proxy_params_common; include proxy_params_static; expires 60d; log_not_found off; } location = /robots.txt { include proxy_params_common; include proxy_params_static; expires 1d; log_not_found off; } # Deny access to files like .htaccess or .htpasswd location ~ /\.ht { deny all; }________________________________________________________
Now if i only know where to put your block exactly, it was perfect.
i think above mine CSS/JS bus i not sure.in page speed when I put your above my CSS/js one of the scripts gone in the warning
(is actually good)When I put him in the end next to the robots.txt location I still got one script more.
if you only recommended me where exactly put it is perfect,
this because we know is working.i got errors sometimes…
with Nginx is not easy…
locksmithunit.es
locksmithunit.cat
do F12(index):1 Unchecked runtime.lastError: The message port closed before a response was received.
I’m afraid I indeed cannot validate your nginx config, but these things I am certain of:
* the snippet provided is what I use on one of my servers that runs nginx
* the 404 handler did work on the test-site
* I just tested https://locksmithunit.es and it works there as well (try e.g. https://locksmithunit.es/wp-content/cache/autoptimize/js/autoptimize_751ad809080497cebc8eff1fe7c7b59c.js to see the redirect to the fallback JS-file)Ok,
I remove the block you offer in the FAQ for Nginx.
I think about that and this not make any sense, my css/js block is open for everything.
he will read the fallback.I think in your FAQ they try to explain if you don’t have something like that this how
should be, but in my case, Engintron (Nginx) has an open string to read all the files.is mean Nginx will read it and create the fallback without any issue in the same block.
and this the file you give me:
https://locksmithunit.cat/wp-content/cache/autoptimize/js/autoptimize_fallback.jshe still working.
this without a special block.
(with the original blocks I showed you)if you can run the last test (if you different test from the link you provide me)
tell me if everything fine I will keep it like this.as i said links fall back working without Nginx block to the PHP hendler:
https://locksmithunit.cat/wp-content/cache/autoptimize/js/autoptimize_fallback.js
https://locksmithunit.es/wp-content/cache/autoptimize/js/autoptimize_fallback.jsBTW,
Maybe is good put in apache one just in case:
#ErrorDocument 404 /wp-content/autoptimize_404_handler.php?error=404this one is good Frank?
tell me if is ok, i am sorry Frank is the last time.
-
This reply was modified 5 years, 2 months ago by
Nadav Levi.
Hey 🙂
is working without any block in Nginx.I verified that.
I only think is better put ErrorDocument 404 in the .htacsses, just in case
nginx not serve the fallback.
( Nginx do a good job, but can make sure with apache as well )what did you recommend?
ErrorDocument 404 /wp-content/autoptimize_404_handler.php?error=404
or
ErrorDocument 404 /index.php?error=404Ok, i found this:
# https://codex.ww.wp.xz.cn/Creating_an_Error_404_Pagethis is the hardcoded of 404 ships with WordPress.
this said to do this:
ErrorDocument 404 /index.php?error=404they said NOT redirect to the PHP directly (in our case, AO 404 PHP handler ).
TO DO THIS:
ErrorDocument 404 /index.php?error=404but when i get a real 404 like HTML page, is not redirect to the
shtml of cPanel error pages…in my htacsses is look like that now:
# To ensure the server finds your 404 page, add the following line to your .htaccess file: # https://codex.ww.wp.xz.cn/Creating_an_Error_404_Page ErrorDocument 404 /index.php?error=404 # Autoptimize | AO 404 Hendler #ErrorDocument 404 /wp-content/autoptimize_404_handler.php?error=404 # Apache cPanel Default #ErrorDocument 400 /400.shtml #ErrorDocument 401 /401.shtml #ErrorDocument 403 /403.shtml #ErrorDocument 404 /404.shtml #ErrorDocument 406 /406.shtml #ErrorDocument 500 /500.shtmland AO Hendler shows the fallback:
https://locksmithunit.com/wp-content/cache/autoptimize/js/autoptimize_fallback.js
https://locksmithunit.cat/wp-content/cache/autoptimize/js/autoptimize_fallback.js
https://locksmithunit.es/wp-content/cache/autoptimize/js/autoptimize_fallback.jsI comment on the shtml, because they not work 🙁
Tell me about the :
ErrorDocument 404 /index.php?error=404is already active in the htacsses, and your handler shows the fallbackfile.
-
This reply was modified 5 years, 2 months ago by
The topic ‘404 hendler AO + 404 redirect homepage plugin’ is closed to new replies.