HI
weird issue I just discovered with last two versions of Newsmag, running PHP 8.3x on Apache.
When I create a wildcard redirect in the htacess file (so, for example – my-image-2010.jpg –> /images/mygenericpic-800×600.jpg
Instead redirects to a post 404 page, and won’t redirect to the fallback image. Happens to all sites running Newsmag, but not on sites NOT running Newsmag.
Anybody else have this issue?
Thanks.
To clarify, I am not doing a single 301 redirect, I am doing a wholesale blanket “if the image no longer exists load this generic image.”
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule \.(gif|jpe?g|png|bmp) /CALIF/default-CAnewswire-800x600.jpg [NC,L]
</IfModule>
Hi simchris,
Please try this code in .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^CALIF/default-CAnewswire-800x600\.jpg$ - [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(?:gif|jpe?g|png|bmp)$ /CALIF/default-CAnewswire-800x600.jpg [L,NC]
If it is not working, you can try this code in functions.php in the child theme
add_filter('redirect_canonical', function($redirect_url, $requested) {
if (preg_match('/\.(gif|jpe?g|png|bmp)$/i', $requested)) {
return false; // stop WP from “guessing” a post for missing images
}
return $redirect_url;
}, 10, 2);
I hope one of those will work for you!
Hi,
If it is still not working, maybe you can try a plugin?https://wordpress.org/plugins/404-to-301/ and try this regex redirection rule:
Source URL: ^.*\.(jpg|jpeg|png|gif|bmp)$
Target URL: https://yourdomain.com/path/to/fallback-image.jpg
Match: Regex
Action: Redirect to URL (301 or 302)
Hi
there is some fundamental issue with the current theme install where htaccess directives seem to be entirely ignored, such as redirects and stuff like pagespeed = on kind of things.
Going to have to try default theme to debug, as disabling all plugins had not effect.
Trying to use WP-STAGING plugin, but their pesky platform does not support external uploads locations (e.g., /root/uploads/ vs /root/wp-content/uploads/ … ) which breaks the image links ((sigh)).
Having one of those months over here.
I forget — these days, does Newsmag lose all its settings if I temporarily switch themes and turn off td-composer ?
Hello,
If WP Staging doesn’t work, you can try Duplicator.
When a default theme is set instead of the Newsmag theme, the settings in the theme panel should not be lost, but what will be lost are the blocks set in the widgets for the sidebars, and if you want to do this test live, I would recommend trying only after a full backup so that it is easier to restore in case of problems.
Thank you!
okay… having the server hosting company look into this as the htaccess directives all work on PHP 7.4x and do not on 8.3x, which is bizarro. Apparently the settings not fully inherited from 7 to 8.
Guessing it’s a AllowOverride All directive missing.
One general support note — while we have our own server, it looks like some hosting companies are starting to deprecate use of the .htaccess file, but then suggest using plugins that are insecure to fix things like redirect missing images to a default.
I only mention as this might be a good ‘option’ you could fairly simply add to both Newsmag and Newspaper as a useful function feature. Basically allowing a default image to be used when a post main, featured image and/or thumbnail deleted.
Will let you know the final result once I hear back from hosting provider. With my new PC here, I don’t currently have an SSH client installed to get into the server core stuff preferring to work with the Plesk panel.
#wheeeeee 🙂
Hi simchris, thanks for the feedback, we hope that eventually the situation will be resolved.
Yes, the idea about an optin like the one mentioned is good, maybe we could force a new optin into the placeholder https://i.imgur.com/sda0sua.png I’ve added it to the list and our developers will check it.
Thank you!
Hi
okay, we sorted the issue with php 8 and htaccess.
Couple of things – in our case with apache and plesk and nginx, the serve proxy checkbox needed to be toggled.
Second, some of the ‘recommended’ security directives to block access to certain wordpress folders seemed to break redirects on one site.
Finally, one additional unexpected issue was the sunsetting of apache pagespeed as of April 2025. So, the directives we had at top of the htaccess for that were generating errors, since does not work at all with php8.
The image redirects with htaccess now working, but man that hurt with Google image search getting 10,000 404 newsmag pages loaded. Doh.
As with anything these days, folks moving to php 8 should totally revisit their htaccess file if using one, or if using multiple in different folders, sub domains or whatever.
