WordPress.org

Ready to get started?Download WordPress

Forums

Redirection
Redirection Loop Fix (10 posts)

  1. MonkeyPress
    Member
    Posted 1 year ago #

    This is an amazing plugin, though often I get users who end up creating redirect loops when they change a page url a couple of times. Is there a permanent fix that could be implemented in the plugin to help catch the redirection loops? It seems like it would simply need to check the source/destination against the destination/source of existing redirects.

    Thoughts?

    http://wordpress.org/extend/plugins/redirection/

  2. tccarter
    Member
    Posted 1 year ago #

    Any movement on this issue? I have a number of sites that are experiencing the same issue so I've disabled the plugin hoping this will be fixed with a new release, is that coming?

  3. MonkeyPress
    Member
    Posted 1 year ago #

    I haven't heard anything from the developer, though figured it was time to dig into the code. Here's a fix for this issue. In the /wp-content/plugins/redirection/models/redirect.php file add this line:

    $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}redirection_items WHERE url='%s' AND action_type='%s' AND action_data='%s';", array($data['action_data'], $data['action_type'], $data['url'])));

    just before this insert statement on line 210:

    $wpdb->insert( $wpdb->prefix.'redirection_items', $data );

  4. tccarter
    Member
    Posted 1 year ago #

    Fantastic! I'll give it a shot. Thanks for the patch.

  5. MonkeyPress
    Member
    Posted 1 year ago #

    I probably should have added a comment to that code. This fix deletes any redirect that has the new redirects destination as its source url and its destination url as the new redirections source url.

  6. trade-gate
    Member
    Posted 11 months ago #

    Hello MonkeyPress,

    I inserted the code you refer to above in my redirect php file. I suppose it made some changes but my problem stil persists. Maybe I have a different type of problem. Sorry I have very elementary knowledge on the issue.

    My problem is the following: I renamed some of the pages I prepared for http://www.trade-gate.net, and I am afraid I renamed some to their initial names and this now caused a problem of redirect loop such as the one in the following page: http://www.trade-gate.net/eurostrong-televizyon-koltuklari/

    I am desperately trying to find a solution to it. What can I do? I installed Redirect plugin and then removed what seemed to be redirection but it did not work out so I uninstalled the plugin again. Nothing changed.

    How can I fix this issue?

    Thank you very much - in advance.

  7. MonkeyPress
    Member
    Posted 11 months ago #

    If you're running the redirection plugin that I referenced and uninstalled it, the redirection loop should disappear. You might have some .htaccess redirects set up that are causing a loop now.

    Now the fix that I posted won't clear up old loops automatically unless you update the page that is causing the loop. To find the redirect loop you need to navigate to the redirection plugin and then do a search for the post URL under the modified posts group. Next delete any of the entries that have the new url as the source of a redirect.

  8. trade-gate
    Member
    Posted 11 months ago #

    Thank you very much. I will do that and inform you the outcome.

    Have a nice day.

  9. trade-gate
    Member
    Posted 11 months ago #

    Dear MonkeyPress,

    I did as you recommended to clear up the old loops, although I could not pinpoint to a specific direction that explained why I was getting the loops. I disabled directions, then deleted them completely and even disabled Redirection but still I was getting the loops again.

    Somehow, I thought, there should be a way of clearing the memory of wordpress for the name changes I made and it seemed unrealistically complicated to work on the codes for such a simple thing. In the forums people were advising each other to make several code changes, referring to rewriting of .htaccess or the codes of the theme but I was afraid to do them as I could have totally cause a serious crash.

    But finally after spending almost three days in desperation, and also suspecting that it might be related with my WordPress SEO plugin (as it sets the way your pages will be named according to your choise) I solved the problem :-)) And-as I suspected, it was extremely simple.

    I am explaining the steps so that others who have a similar problem may solve their problem too. (unless of course their problem is related to another aspect of the problem.)

    For me, the problem started when I rechanged the title of a page to the very firts title I used i.e.to http://www.trade-gate.net/eurostrong-televizyon-koltuklari/ from http://www.trade-gate.net/masaj-koltugu/. Afterwards, when I wanted to access this new page, I was getting an error saying that I have a "redirection loop"

    I then started checking everything on my page and on the WordPress SEO plugin that has a system for automatically setting the way page titles will be formed, I realised that my new page's "page short name" was remaining as masaj-koltuklari whereas the slug of the page became eurostrong-televizyon-koltuklari when I changed the title.

    When I corrected the page short name so that it would became the same as the page slug, the loop problem simply disappeared. I made the same change for 6-7 other pages that I had redirection loop problem with and it worked for them too. Now I do not have a loop anymore.

    :-))) I am so happy.

    I already made the change on the redirection.php file that you proposed above, so I am not sure whether my problem could have been solved without this change or not, but still I would like to thank you very much for your assistance. :-)

    Have a nice day.

  10. connectmukesh
    Member
    Posted 2 months ago #

    Hey I was facing the same problem - redirect loop - after I added sitemap - page on my site. What worked for me was that I had put two redirections for /sitemap and /sitemap-xml, and once I removed those re-directions the link started working. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic