Author Topic: 404 redirection of child pages  (Read 284 times)

Offline sky writer

  • Posts: 926
404 redirection of child pages
« on: March 29, 2018, 12:00:30 PM »
I have the 404 module v4 and shorturl running on a site.

I have a site tree which is now three levels deep e.g.

home
about
 - history
    - news

The old tree was like this:
home
about
history
 - news

So, for instance, I have a redirect set up for "history" to go to "about/history"
This works.

But I also need a redirect for "history/news" to go to "about/history/news"
I have tried entering rules "news", and also "history/news" pointing to "about/history/news" but am always redirected to the "history" page.

Is there a way to redirect to a child page and separately to the child of a child page.

Thank you.

Online Ruud

  • Posts: 3608
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: 404 redirection of child pages
« Reply #1 on: March 29, 2018, 12:08:55 PM »
The module will execute the first match it finds.
Set it up with the longest rule first:

1. > history/news > about/history/news/
2. > history > about/history/

Offline sky writer

  • Posts: 926
Re: 404 redirection of child pages
« Reply #2 on: March 29, 2018, 12:34:16 PM »
I've tried this, but it doesn't seem to work.

I also notice that the last rule entered does not always display at the bottom of the rule list.  Not sure what determines their order.  But even when the displayed order has
 > history/news > about/history/news/
above
 > history > about/history/

I am redirected to about/history/

If I remove the " > history > about/history/" rule, then the " > history/news > about/history/news/" rule works as expected.

Offline sky writer

  • Posts: 926
Re: 404 redirection of child pages
« Reply #3 on: March 29, 2018, 12:44:44 PM »
I've noticed something.  Not sure if it is relevant.

If I enter rules like so:

rule 1 > about
rule 2 > about
rule 4 > about
rule 3 > about

then I delete "rule 4 > about" , it is removed from the list AND the database as expected

But then if I add
rule 4 > about

the rules are again displayed like so:
rule 1 > about
rule 2 > about
rule 4 > about
rule 3 > about

and that is the order they are shown in the database again, as well.

I've looked at all the factors in the database, and I can't understand why this happens.

Online Ruud

  • Posts: 3608
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: 404 redirection of child pages
« Reply #4 on: March 29, 2018, 02:36:41 PM »
Hmm..
This should not be the case..

The order is based on the (primary key) "404_id" in the table used to store the rules.
Adding a new rule should always creat a new "404_id" and end up in the bottom of the list...

In a next version I will nake sure this field is forced to be used as order.

For now it is probably best to modify the existing rules to have them in the right order as shown in the backend.

Offline sky writer

  • Posts: 926
Re: 404 redirection of child pages
« Reply #5 on: March 29, 2018, 05:45:37 PM »
I've been playing/testing this and there is definitely something strange occurring, but I can not find a logical explanation.

Yes, each NEW entered rule gets a new sequential "404_id".  But the row does not always get sorted to the bottom in the table.  Rather than try to explain in detail what I experienced, I will suggest to create a sequence of rules.  Then start deleting some, then renaming some, and then adding new rules, and finally add some of the original rules back in.  If you do not get strange results, please let me know, and I will gladly show you what I am seeing.

Offline sky writer

  • Posts: 926
Re: 404 redirection of child pages
« Reply #6 on: March 29, 2018, 05:49:54 PM »
The module will execute the first match it finds.
Set it up with the longest rule first:

1. > history/news > about/history/news/
2. > history > about/history/

I also can not get this to work, as explained.  I think it is finding the "history" part first and then defaulting to the "about>history" page
But if I change the rules to the following, it seems to work:

1. > news > about/history/news/
2. > history > about/history/

Offline sky writer

  • Posts: 926
Re: 404 redirection of child pages
« Reply #7 on: March 29, 2018, 05:54:42 PM »
Sorry, please ignore the following.  I am still testing for a working fix...

No matter how I set the rule, I always get the parent page, not the child.  EVEN when I have the child rule listed above the parent.   I'm going to give this a rest.  Sorry for all the posts.


The module will execute the first match it finds.
Set it up with the longest rule first:

1. > history/news > about/history/news/
2. > history > about/history/


I also can not get this to work, as explained.  I think it is finding the "history" part first and then defaulting to the "about>history" page
But if I change the rules to the following, it seems to work:

1. > news > about/history/news/
2. > history > about/history/

Online Ruud

  • Posts: 3608
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: 404 redirection of child pages
« Reply #8 on: March 30, 2018, 10:25:00 AM »
Found the issue for wrong orders.. It was a bit more than just the ordering of rules in the backend..

Released version 1.3 today: https://dev4me.com/modules-snippets/opensource/404/

Fixes and additions:
- fix correct order of rule processing
- fix frontend errormessages when not yet configured
- oneforall pages detected and (optional) used for redirects
- bakery pages detected and (optional) used for redirects
- font change in email report
- added no-report.php with reporting filters for url and browser/bots
- added configuration: only report with referrer

Offline sky writer

  • Posts: 926
Re: 404 redirection of child pages
« Reply #9 on: April 09, 2018, 04:51:14 AM »
I have redirected an old website URL to a new one.  The old site had URL's like oldsite.com/about.php and the new site has newsite.com/about (no trailing .php).
Can I set up a rule for about.php to redirect to my "about" page, and will it only redirect "about.php", or will it also redirect "about"

I want to avoid redirect loops.

Online Ruud

  • Posts: 3608
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: 404 redirection of child pages
« Reply #10 on: April 09, 2018, 10:00:47 AM »
I have redirected an old website URL to a new one.  The old site had URL's like oldsite.com/about.php and the new site has newsite.com/about (no trailing .php).
Can I set up a rule for about.php to redirect to my "about" page, and will it only redirect "about.php", or will it also redirect "about"

I want to avoid redirect loops.
The idea using this module is that it only comes into action when a page is not found.
What happens with or without /pages/ and .php is depending if you are using shorturl. The 404 module tries to detect if shorturl is used (since v1.3) and if so it should redirect to /about/ instead of /pages/about.php.
If the old site did not use shorturl and the new one does, the .htaccess should fix that without the help of the 404 module.

Offline sky writer

  • Posts: 926
Re: 404 redirection of child pages
« Reply #11 on: April 10, 2018, 10:41:00 AM »
If the old site did not use shorturl and the new one does, the .htaccess should fix that without the help of the 404 module.
Thank you.

 

postern-length