aaron13100 / 404solution

404 Solution
https://ajexperience.com/wealthpsychology/404-solution/
4 stars 2 forks source link

Regex Redirect to force display of 404 page #35

Closed janiosarmento closed 1 year ago

janiosarmento commented 1 year ago

Folks, I'm sorry for opening an issue, but I'm getting more and less desperate to get my job done.

Long story short, my site had a page and a bunch of subpages deleted. I (imagine to) need a regex like the below to just display the default 404 page:

/my-deleted-page/.+

However, 404 Solution sometimes captures the missing pages and redirects them to posts, what's not what I need.

I don't have a custom 404 page, and I don't want to create one, for reasons beyond my own will.

What am I missing?

Thank you very much, any help very appreciated!

aaron13100 commented 1 year ago

If you don't want it to automatically redirect to pages then on the options tab you can unselect the 3 options:

Then save the changes and delete all of the redirects that were created automatically.

If you only want pages that match your regex to go to the default 404 page and you do want other things to automatically redirect, then let me know and I'll figure out how to add that feature sometime.

janiosarmento commented 1 year ago

Hi Aaron,

If you only want pages that match your regex to go to the default 404 page and you do want other things to automatically redirect, then let me know and I'll figure out how to add that feature sometime.

That's what I need.

For the time being (there's a deadline on my tail) I exported the automatic redirections generated by the plugin to a CSV and converted them to .htaccess rules, excluding the URLs I need to go to theme's builtin 404 page; now I'm going to keep the plugin only for monitoring the 404.

Thanks for taking time to help me!

aaron13100 commented 1 year ago

Hello. In version 2.31.6 you can now create a custom redirect to the homepage or to the default 404 page. So you should be able to do what you want by creating a regex redirect with the plugin.

Please be careful. Maybe it should match something like /events/(.+)

janiosarmento commented 1 year ago

Hi.

Unfortunately, it's not working as I expected.

I created a rule:

Url: /business-directory/.+ Treat as RegEx Redirect to (Default 404 page) Redirect type: 301 (I didn't change it from the default)

When I access anything under /business-directory/ the browser receives a page with a JavaScript meant to redirect the page to "" (which implies redirect to itself), producing a redirection loop.

Also, when you view the rule (like, when editing it) the value "(Default 404 page)" does not appear, the field seems blank.

Thank you!

aaron13100 commented 1 year ago

Ah. Version 2.31.7 should work. thanks for the feedback.

janiosarmento commented 1 year ago

Hi Aaron,

The JS bit persists on 2.31.7. The setting page now displays the special page as expected.

https___wp-staging_publicknowledgeproject_dev_business-directory_test

I expected to see my theme's 404 page rather than this code.

Thanks!

aaron13100 commented 1 year ago

Maybe the redirect that was setup has to be resaved.

aaron13100 commented 1 year ago

Maybe the page is cached.

aaron13100 commented 1 year ago

If resaving the redirect and clearing the cache doesn't work I'll have to verify that enough log messages are there before I ask you to turn on debug logging and try again and paste the results to pastebin...

janiosarmento commented 1 year ago

Even addind gibberish URLs, it's still producing the JS redirection loop. I have the pastebin link, should I post it here, as a comment?

janiosarmento commented 1 year ago

(Of course I deleted the rule, recreated it, and cleared all caches, as you told me to do.)

aaron13100 commented 1 year ago

Yes please post the pastebin link.

Thanks

On Fri, Dec 16, 2022, 20:22 Janio Sarmento @.***> wrote:

Even addind gibberish URLs, it's still producing the JS redirection loop. I have the pastebin link, should I post it here, as a comment?

— Reply to this email directly, view it on GitHub https://github.com/aaron13100/404solution/issues/35#issuecomment-1355469106, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEBRPCNB4XDIA2YFN4ASUV3WNS6ODANCNFSM6AAAAAATAD6W6Q . You are receiving this because you commented.Message ID: @.***>

janiosarmento commented 1 year ago

https://pastebin.com/3p5ySn4a

aaron13100 commented 1 year ago

Sorry about that. Please try 2.31.8.

janiosarmento commented 1 year ago

Hi, Aaron, thanks for the update!

The Javascript code is not being sent to the client anymore. But rather then rendering the theme's 404 page, the permalinks caught by this rule are generating just a blank screen.

I don't know how to thank you for your help with this matter. Thanks a million!

aaron13100 commented 1 year ago

Thanks for your feedback.

I'm not sure what to do about the blank screen.

You could try redirecting to a custom page instead to see if that works. And you could send me a new log file with the latest version where you get a blank page.

I guess I have an idea to try to fix it, but the changes would take some time and I'm not sure if it will work so I'm not so excited about it.

Message ID: @.***>

janiosarmento commented 1 year ago

Aaron, due to my deadline I had to export the automatic redirections found by the plugin and convert them to .htaccess rules (so that the 404 work out of the box). I'll set another copy of the site this week and run the tests again.

Thanks, and sorry for not being able to provide you with the logs right now.

aaron13100 commented 1 year ago

It should now redirect to the theme's 404 page with version 2.31.9. Thanks for your help testing. I'll be busy around the holidays again so responses may be slower.

aaron13100 commented 1 year ago

I hope this works now. Please open a new issue if not. Thanks