Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum reply redirect URL rewrite issue

Viewing 25 replies - 1 through 25 (of 29 total)
  • Your topic replies URL should be displaying in the format:

    http://localhost/sitename/forum/topic/butterflies/#post-158277

    When I set my bbPress settings to the same settings you use above these are the URL’s:

    Forums base: forum (Note: Default bbPress setting is ‘forums’)
    Topics base: topics (Note: Default bbPress setting ‘topics’)
    Forum Prefix ticked (Note: Default bbPress setting ‘ticked/checked’)
    Forum slug: forums (Note: Default bbPress setting is ‘forum’)
    Topic slug: topic (Note: Default bbPress setting ‘topic’)

    http://localhost/sitename/forum/forums/butterflies/

    http://localhost/sitename/forum/topic/test-topic/

    http://localhost/sitename/forum/topic/butterflies/#post-158277

    I would try resetting your permalinks. In your WordPress Administration Screens navigate to Settings > Permalinks, select a different permalink structure and save. Then select your preferred permalink structure and save again.

    If you have no luck I would read up on the LAMP/MAMP (Linux/Mac, Apache, MySQL, PHP) package you are using on what settings are needed for mod_rewrite to work on your local machine.

    There are also a few (and a few broken links here) installing WordPress Locally
    https://codex.wordpress.org/WordPress_Installation_Techniques#Installing_WordPress_Locally


    apet083
    Participant

    @apet083

    Thanks Stephen. So it is something to do with my rewrite rules? I am using Windows 7 on IIS 7.5 so those links don’t really help me much.
    I have XDebug running on Notepad++ to debug my php code, would it be worth it if I stepped through the code in which it’s creating the URL? If it would be worth it, any idea where to start?
    I have already looked at bbp_get_reply_url method calls in some of the bbp files but nothing has really helped much.

    Thanks
    Ana

    P.s. butterflies is the name of the FORUM, not the topic title. The rewrite ignores the topic title completely.

    Quite sure if you have reset the permalinks as I noted in the previous post if that does not fix it then it is definitely the ‘URL Rewrite’ module settings in IIS. (Thats is if you have it installed as you do need it for rewrites with IIS)

    The easiest Windows option is to use the Microsoft Web Platform Installer (Web PI) and follow the guide outlined here:
    https://codex.wordpress.org/Installing_WordPress#Easy_5_Minute_WordPress_Installation_on_Windows
    http://www.microsoft.com/web/gallery/wordpress.aspx

    If you are manually installing IIS, MySQL & PHP then you have some work ahead of you getting your environment configured correctly and need to make sure you have the ‘URL Rewrite’ module installed and working with IIS http://www.iis.net/downloads/microsoft/url-rewrite#additionalDownloads

    I have not tried any of the ‘WAMP’ (Windows, Apache, MySQL, PHP) packages referenced here but that is another option.
    https://codex.wordpress.org/Installing_WordPress#WAMP


    apet083
    Participant

    @apet083

    Thanks for your reply Stephen. The site is live on Windows Server 2008 with IIS 7.5

    All other links seem to work, it is just when people reply to topics that it jumps around…

    After resetting permalinks on my dev environment and setting the slugs to the WordPress defaults these are the URLS.

    Navigating to a topic from the list of recent topics:
    http://localhost/sitename/forums/topic/test-topic/

    Navigating to a forum from the list of forums:
    http://localhost/sitename/forums/forum/forum-name/

    Navigating to a topic after clicking on a forum from above:
    http://localhost/sitename/forums/topic/test-topic/ (this is consistent with the first link which is good).

    Posting a reply from inside test-topic
    http://localhost/sitename/forums/forum/forum-name/#post-158293

    Posting a reply from http://localhost/sitename/forums/topic/test-topic/#post-158277:
    http://localhost/sitename/sitename/forums/topic/test-topic/#post-158294

    Note that it doubled the sitename ^ but this doesn’t seem to affect it and lands back at the topic which is what I want.

    Using the default bbPress settings I just threw up a IIS install of WP 3.5 and bbPress 2.2.3

    http://localhost:81/forums/
    http://localhost:81/forums/forum/test-forum/
    http://localhost:81/forums/topic/test-topic/

    For the test topic I added a reply and clicked submit and the resulting URL is correct

    http://localhost:81/forums/topic/test-topic/#post-7


    apet083
    Participant

    @apet083

    I still can’t think of what the problem could be. I will keep hunting around. Thanks.


    apet083
    Participant

    @apet083

    Hi Stephen @netweb. I just tried creating a WordPress site from scratch with bbpress. When I clicked on reply it redirected me back to the wrong page again. It seems like its my settings with IIS.
    If I use the WordPress default permalink structure (no rewrite) it still does the same thing.

    What could be in your IIS that I don’t have? Where would this setting be located?

    Also, what version of PHP and MySQL do you have? I have PHP 5.3 MySQL 5.1

    Thanks

    My apologies, I meant to write this quite a few hours ago 😉

    It has been quite a while since I last configured an IIS server for WordPress so I am a bit rusty in this regard. The details of what I am using at on the install I referred to above:

    – Windows 2008 Server SP2, IIS 7.0, MySQL 5.1, PHP 5.2.14

    I don’t see the Windows 7 vs Server 2008 R2 being an issue nor IIS 7.0 vs 7.5 as the current version of ‘IIS URL Rewrite Module 2’ is still the most current version.

    Here is my web.config file for that site created within IIS (I have made no manual config changes to the file etc) when I created the site above.


    apet083
    Participant

    @apet083

    Thanks Stephen. Unfortunately the web.config made no difference 🙁 Neither did changing the permalinks to every option or removing slugs etc.
    I also tried setting up a fresh WP Install with a clean copy of bbPress but it did the same thing.
    I am stumped and completely out of options at the moment :-/
    I look at my network stack trace and notice when I hit “Submit” the error code returned is a 302 Moved Temporarily, this is when it redirects to the wrong URL.
    Debugging the code, it seems to hit the same place in query.php about 2-3 times meaning it’s loading the correct page, getting redirected to the wrong page, then loading the wrong page…
    Thanks anyway, hopefully someone else will have this problem with a solution at some point!

    Just as a thought in that it wouldn’t hurt to try is to compare some of the latest and previous versions of bbPress to isolate if it is an IIS issue or a bbPress issue for certain.

    The latest /trunk (overnight changes are always expected):
    https://bbpress.trac.wordpress.org/browser/trunk

    Also try 2.0, 2.1 or any build really via https://bbpress.trac.wordpress.org/browser/tags

    (Each page has a ‘.zip’ link to download the particular build)


    mohdrafie
    Participant

    @mohdrafie

    Hi guys,

    I had similar issue as well at some point.

    Has anyone try it on a Linux server as see if it makes any difference?

    Otherwise, I would be a good lead to find the php file for the comment post and made slight modification or see what influence the redirection.

    What I will do is to make quick test and see and keep you updated. If you found anything, kindly share. Cheers guys!

    I just came across this post and it might help

    WordPress on Windows Server 2012 with IIS 8 and SQL Server 2012


    apet083
    Participant

    @apet083

    Thanks Stephen, that was a very nice blog and it’s good to see that people are updating the documentation as the years go on. The PHP manager was a good install that I did not have and it touched on some issues that I spent hours trying to fix and will surely be of benefit to someone.

    However, the configuration used was practically the same as mine and did not fix the redirect problem 🙁

    Thanks anyway.

    Ana


    apet083
    Participant

    @apet083

    Wow. Stephen I just read your post about trying the past versions of bbPress to isolate the issue. I started at 2.0 and the redirects WORKED! I moved up each time my tests were successful. 2.0 – 2.0.3 work perfectly.

    As soon as I upgrade to 2.1 and upwards, the redirects break again!

    I think it is safe to say it is a bbPress issue. Hopefully someone can look into it 🙂 I will try to examine the redirect differences between 2.0.3 and 2.1 and will post if I find anything useful.

    For now I will use bbPress 2.0.3 and hopefully the issue will get sorted 🙂

    Thanks so much for your help!

    Ana

    Hmmmm…. Progress…. That’s good news

    I will try to get some time and have a look through the patches for 2.1 and see if anything stands out.

    The other problem is that as yet I have not been able to duplicate your bug on my IIS install, I will see if I can spin up a Windows 7/IIS 7.5/PHP 5.3/MySQL 5.1 VM this week and take a further look.


    apet083
    Participant

    @apet083

    Yes, would be good if someone, anywhere could replicate my issue – but at least there’s something to go on now.

    I will keep hunting around for similar problems/solutions. Let me know if you make any progress, thanks again 🙂

    Ana


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    The stack here is:

    • `bbp_get_reply_url()`
    • `bbp_get_topic_permalink()`
    • `get_permalink( $topic_id )`

    The only place this could occur is if `bbp_get_reply_url()` is passed both a `$reply_id`, and a `$redirect_to`, and the `$redirect_to` is the forum permalink, which shouldn’t happen. `bbp_get_redirect_to()` is what gets it in trunk, which is a wrapper for `$_REQUEST[‘redirect_to’]`.

    Which is to say, if you have a `$_REQUEST[‘redirect_to’]` field being submitted with the forum permalink, that’s where it will go. Otherwise, I don’t see any other way this could happen in bbPress core.


    apet083
    Participant

    @apet083

    Hi @johnjamesjacoby, thanks for your reply and for the helpful places to look. I have debugged functions.php in bbpress/includes/replies and it seems that the `redirect_to` is being set to the forum’s URL as in this image:

    http://dl.dropbox.com/u/100066470/replyURL.PNG

    Thus giving the wrong `reply_url` at the end. Where does `redirect_to` get set?

    Thanks


    apet083
    Participant

    @apet083

    O.M.G I have finally come across the solution to my problem! Well I have only tested it in my local environment a couple of times and the issue has gone away so hopefully it’s fixed for good!

    https://bbpress.trac.wordpress.org/ticket/2155

    The solution was to change the `bbp_redirect_to_field()` function. I changed this function located in bbpress\includes\common\template-tags.php and the redirects now work!

    Thanks bbPress team =)

    Modified function:

    `function bbp_redirect_to_field( $redirect_to = ” ) {

    // Make sure we are directing somewhere
    if ( empty( $redirect_to ) ) {
    if ( isset( $_SERVER[‘REQUEST_URI’] ) ) {
    $redirect_to = ( is_ssl() ? ‘https://’ : ‘http://’ ) . $_SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’];
    } else {
    $redirect_to = wp_get_referer();
    }
    }

    // Remove loggedout query arg if it’s there
    $redirect_to = (string) esc_attr( remove_query_arg( ‘loggedout’, $redirect_to ) );
    $redirect_field = ”;

    echo apply_filters( ‘bbp_redirect_to_field’, $redirect_field, $redirect_to );
    }`

    Thats great news, would you mind adding a comment to that ticket #2155 in trac with details of your setup and results from your testing.


    apet083
    Participant

    @apet083

    Done. Thanks for your help 🙂

    Thanks 🙂


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    The code above just removes the redirect to field completely, which can’t possibly work correctly.


    apet083
    Participant

    @apet083

    Well I don’t know how or why but as soon as I made that change, the issue went away and nothing else has broken (yet). As soon as I changed the code back to how it was, the issue reappeared. So since I have nothing else to go on, I will take this as a solution.


    iamnotadoll
    Participant

    @iamnotadoll

    I’m having this issue as well. Something is happening to my URLS when posting replies.

    The site is running on ISS 7, the URL Rewrite Module has been installed at it is working perfectly fine with pretty permalinks on my posts and categories.

    Posting a new topic will redirect me to that topic’s page, so that’s working.

    The only thing that’s not working is the redirect when posting a reply – it’s redirecting me all over the place, sometimes back to the parent forum, sometimes to an error page, sometimes back to the main forum index.

    Is there some code that I can modify so that when someone hits ‘submit’ to post a reply, it just refreshes the page or something, instead of redirecting to random places?

Viewing 25 replies - 1 through 25 (of 29 total)
  • You must be logged in to reply to this topic.
Skip to toolbar