Announcement

Collapse
No announcement yet.

Apache redirect not working because of '?routestring=xxx'

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Apache redirect not working because of '?routestring=xxx'

    I had an article I published; I decided I wanted it to be a forum post instead, so I copied it and made a new forum post, and deleted the article.

    I then decided I wanted to make the old article's URL redirect to the new forum article, so I created the usual Apache redirect in my .htaccess file. It doesn't work, because the redirected url gets this "routestring" language appended to it.

    Since these are really long URLs, this is kinda hard to read, but here's the .htaccess:

    Code:
    Redirect permanent /vb/news-and-articles/news/222-video-sept-7th-open-meeting-on-removal-of-a-director        https://mydomain.com/vb/forum/the-preserve-community/hoa-business/223-video-recording-of-sept-7th-2018-open-meeting
    When you click on a link to go to the OLD article, it does not forward to the forum post as it should, but returns "Invalid Page URL. If this is an error and the page should exist, please contact the system administrator and tell them how you got this message."

    Here is the actual URL that gets sent to the browser. It is the correct forum post URL, except it has this ?routestring=xxxx (the previous URL) appended to it, which makes it malfunction.

    Code:
    https://mydomain.com/vb/forum/the-preserve-community/hoa-business/223-video-recording-of-sept-7th-2018-open-meeting?routestring=news-and-articles/news/222-video-sept-7th-open-meeting-on-removal-of-a-director

    I assume that VB is adding this, but why would that be and is there anything I can do to correct this?

  • #2
    It's necessary to maintain the controller class / function / id parameters.

    I'm slightly confused. If you deleted the article the old URL would no longer exist which would result in an invalid page URL error.

    Comment


    • #3
      Thanks for hijacking my thread.

      I didn't get any answer to the actual question. This has nothing to do with VB3 or VB4. I simply, in VB 5, had an article pubished. I decided I wanted it to be a forum post instead, so I rewrote it as a forum post and deleted the article. Then I just wanted to make a redirect so the old article URL went to the new forum URL. But it doesn't work, because some thing adds this "?routestring=xxx" to the URL which makes it malfunction. I will paste again the info here:

      Since these are really long URLs, this is kinda hard to read, but here's the .htaccess:
      (the first part is the old URL, the second part is the new URL)

      Code:
      Redirect permanent /vb/news-and-articles/news/222-video-sept-7th-open-meeting-on-removal-of-a-director        https://mydomain.com/vb/forum/the-preserve-community/hoa-business/223-video-recording-of-sept-7th-2018-open-meeting
      When you click on a link to go to the OLD article, it does not forward to the forum post as it should, but returns "Invalid Page URL. If this is an error and the page should exist, please contact the system administrator and tell them how you got this message."

      Here is the actual URL that gets sent to the browser (by the above Apache redirect). It is the correct forum post URL, except it has this ?routestring=xxxx (the previous URL) appended to it, which makes it malfunction.

      Code:
      https://mydomain.com/vb/forum/the-preserve-community/hoa-business/223-video-recording-of-sept-7th-2018-open-meeting?routestring=news-and-articles/news/222-video-sept-7th-open-meeting-on-removal-of-a-director
      I assume that VB is adding this, but why would that be and is there anything I can do to correct this?

      Comment


      • #4
        --- I've deleted the off-topic and irrelevent posts.

        1) Make sure it is above the main redirect in the .htaccess file.
        2) Add ' [L]' (there is a leading space) at the end of your redirect.

        It should then pass the new URL to vBulletin's main redirect.

        The other way is by manipulating the database directly but that is more difficult.
        Last edited by Wayne Luke; Mon 17th Sep '18, 12:07pm.
        Translations provided by Google.

        Wayne Luke
        The Rabid Badger - a vBulletin Cloud customization and demonstration site.
        vBulletin 5 Documentation - Updated every Friday. Report issues here.
        vBulletin 5 API - Full / Mobile
        I am not currently available for vB Messenger Chats.

        Comment


        • #5
          Thanks - what do you mean by the "main redirect"?

          Comment


          • #6
            The main redirect is marked in the .htaccess file:


            # Main Redirect
            RewriteCond %{REQUEST_URI} !\.(gif|jpg|jpeg|png|css)$
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ index.php?routestring=$1 [L,QSA]
            Originally posted by StephenKay View Post
            Thanks - what do you mean by the "main redirect"?

            Comment


            • #7
              The links in the subject are not clear
              I develop real links and not examples
              I think you can not redirect article links to forum topics
              Due to differences in subject ID and articles

              Comment


              • StephenKay
                StephenKay commented
                Editing a comment
                Thanks, but you apparently do not understand what we are talking about here.

            • #8
              Originally posted by In Omnibus View Post
              The main redirect is marked in the .htaccess file:


              # Main Redirect
              RewriteCond %{REQUEST_URI} !\.(gif|jpg|jpeg|png|css)$
              RewriteCond %{REQUEST_FILENAME} !-f
              RewriteCond %{REQUEST_FILENAME} !-d
              RewriteRule ^(.*)$ index.php?routestring=$1 [L,QSA]
              I see - you are talking about doing the redirect in the vbfolder/.htaccess file; I was trying to do it in my root-level .htaccess file.

              So you are saying I need to do the redirect with the mod-rewrite syntax (and put ' [L]' at the end)? I was trying to do it with the simple 'redirect permanent' syntax. I tried finding some examples of how to use mod_rewrite for targeting a single page and didn't come up with anything yet that I understand. Can you post an example? Thanks much.

              Comment


              • #9
                Code:
                RewriteRule /news-and-articles/news/222-video-sept-7th-open-meeting-on-removal-of-a-director /forum/the-preserve-community/hoa-business/223-video-recording-of-sept-7th-2018-open-meeting [R=301,L]
                https://learnwebtutorials.com/redire...in-mod_rewrite
                Translations provided by Google.

                Wayne Luke
                The Rabid Badger - a vBulletin Cloud customization and demonstration site.
                vBulletin 5 Documentation - Updated every Friday. Report issues here.
                vBulletin 5 API - Full / Mobile
                I am not currently available for vB Messenger Chats.

                Comment


                • #10
                  I put this in exactly as you wrote it, above the Main Redirect. It doesn't work, it still gets the routestring appended to it....

                  Question:

                  My vb files are not in the root directory. They are in mydomain.com/vb.

                  Do I need to enable this?, and change it to RewriteBase /vb/ ?

                  # In some cases where you have other mod_rewrite rules, you may need to remove the
                  # comment on the following RewriteBase line and change it to match your folder name.
                  # This resets the other mod_rewrite rules for just this directory
                  # If your site was www.example.com/forum, the setting would be /forum/
                  #RewriteBase /

                  Comment


                  • #11
                    Only if you have an .htaccess or other rewrites above your vBulletin directory.
                    Translations provided by Google.

                    Wayne Luke
                    The Rabid Badger - a vBulletin Cloud customization and demonstration site.
                    vBulletin 5 Documentation - Updated every Friday. Report issues here.
                    vBulletin 5 API - Full / Mobile
                    I am not currently available for vB Messenger Chats.

                    Comment


                    • #12
                      Sorry, it's still not clear to me. Yes, I have an .htaccess file at root level of the site /
                      It's not doing much. But here is the whole thing. I'm no expert with Apache at all, and as I said your suggested solution above doesn't work so there must be something I'm doing wrong. I do put a few redirects in there from time to time, that's about my level of expertise.

                      Just to keep unsavories out, I've renamed the domain to mydomain. This is my .htaccess file at root / :

                      Code:
                      RewriteEngine on
                      RewriteCond %{HTTP_HOST} ^mydomain\.net$ [OR]
                      RewriteCond %{HTTP_HOST} ^www\.mydomain\.net$
                      RewriteRule ^/?$ "\/vb/home" [R=301,L]
                      
                      ErrorDocument 404 /errors/404.html
                      
                      Redirect permanent /documents         https://mydomain.net/vb/documents
                      Redirect permanent /contacts          https://mydomain.net/vb/contacts
                      
                      AddHandler application/x-httpd-php71 .php .php5 .php4 .php3

                      Comment


                      • #13
                        I am not sure how much clearer it needs to be. You have an .htaccess file in the directory above vBulletin. This means you need to set the RewriteBase in the vBulletin .htaccess file. All changes to how vBulletin does its redirects need to go into the vBulletin .htaccess file.



                        Translations provided by Google.

                        Wayne Luke
                        The Rabid Badger - a vBulletin Cloud customization and demonstration site.
                        vBulletin 5 Documentation - Updated every Friday. Report issues here.
                        vBulletin 5 API - Full / Mobile
                        I am not currently available for vB Messenger Chats.

                        Comment


                        • #14
                          I was looking for a definitive "yes, you must change the RewriteBase to /vb/ ". Thanks.

                          Comment


                          • #15
                            OK, well I changed the RewriteBase:

                            Code:
                                RewriteBase /vb/
                            I put in your suggested redirect, above the main redirect:

                            Code:
                                RewriteRule /news-and-articles/news/222-video-sept-7th-open-meeting-on-removal-of-a-director /forum/the-preserve-community/hoa-business/223-video-recording-of-sept-7th-2018-open-meeting [R=301,L]
                            
                                # Main Redirect
                                RewriteCond %{REQUEST_URI} !\.(gif|jpg|jpeg|png|css)$
                                RewriteCond %{REQUEST_FILENAME} !-f
                                RewriteCond %{REQUEST_FILENAME} !-d
                                RewriteRule ^(.*)$ index.php?routestring=$1 [L,QSA]
                            I still cannot get it to work. The resulting redirected URL still has the routestring after it...


                            Comment

                            Related Topics

                            Collapse

                            Working...
                            X