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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • StephenKay
    Senior Member
    • Apr 2003
    • 437

    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[COLOR=#FF0000]?routestring=news-and-articles/news/222-video-sept-7th-open-meeting-on-removal-of-a-director[/COLOR]

    I assume that VB is adding this, but why would that be and is there anything I can do to correct this?
  • In Omnibus
    Senior Member
    • Apr 2010
    • 2310

    #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

    • StephenKay
      Senior Member
      • Apr 2003
      • 437

      #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[COLOR=#FF0000]?routestring=news-and-articles/news/222-video-sept-7th-open-meeting-on-removal-of-a-director[/COLOR]
      I assume that VB is adding this, but why would that be and is there anything I can do to correct this?

      Comment

      • Wayne Luke
        vBulletin Technical Support Lead
        • Aug 2000
        • 73979

        #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 17 Sep '18, 11:07am.
        Translations provided by Google.

        Wayne Luke
        The Rabid Badger - a vBulletin Cloud demonstration site.
        vBulletin 5 API

        Comment

        • StephenKay
          Senior Member
          • Apr 2003
          • 437

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

          Comment

          • In Omnibus
            Senior Member
            • Apr 2010
            • 2310

            #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
            Thanks - what do you mean by the "main redirect"?

            Comment

            • m-d-luffy
              Senior Member
              • Sep 2018
              • 109

              #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
              العاب - game
              العاب - game
              العاب - game

              https://www.youtube.com/@abdur7maan​
              ​

              Comment


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

              #8
              Originally posted by In Omnibus
              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

              • Wayne Luke
                vBulletin Technical Support Lead
                • Aug 2000
                • 73979

                #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]
                Translations provided by Google.

                Wayne Luke
                The Rabid Badger - a vBulletin Cloud demonstration site.
                vBulletin 5 API

                Comment

                • StephenKay
                  Senior Member
                  • Apr 2003
                  • 437

                  #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

                  • Wayne Luke
                    vBulletin Technical Support Lead
                    • Aug 2000
                    • 73979

                    #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 demonstration site.
                    vBulletin 5 API

                    Comment

                    • StephenKay
                      Senior Member
                      • Apr 2003
                      • 437

                      #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

                      • Wayne Luke
                        vBulletin Technical Support Lead
                        • Aug 2000
                        • 73979

                        #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 demonstration site.
                        vBulletin 5 API

                        Comment

                        • StephenKay
                          Senior Member
                          • Apr 2003
                          • 437

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

                          Comment

                          • StephenKay
                            Senior Member
                            • Apr 2003
                            • 437

                            #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...