Redirect QUERY_STRING

#860503
Viewing 9 replies - 1 through 9 (of 9 total)
  • Hello,

    We apologize for the issue you are facing with redirecting your URLs. To redirect the specified URLs with query strings to a new location, you can add a redirection rule to your .htaccess file. Here’s how you can do it:

    1. Access your .htaccess file: You can edit the .htaccess file directly from the WordPress dashboard by navigating to Rank Math SEO → General Settings → Edit .htaccess.
      Navigate to edit .htaccess

    2. Add the following code snippet after #END WordPress:

      RewriteEngine On
      RewriteCond %{QUERY_STRING} option=com_content&view=article&id=1247 [OR]
      RewriteCond %{QUERY_STRING} option=com_content&view=article&id=1224 [OR]
      RewriteCond %{QUERY_STRING} option=com_content&view=article&id=1226 [OR]
      RewriteCond %{QUERY_STRING} option=com_content&view=article&id=1253
      RewriteRule ^index.php$ http://your-site.com/andrew-fell-asleep-zzz [R=301,L]

      This code checks for the specific query strings and redirects them to the desired URL.

    3. Save Changes: After adding the code, make sure to click on Save Changes.
      Save Changes

    You can also use an htaccess tester to ensure that your rules are correct before applying them.

    If you still have any questions or if the issue persists, please reply to this ticket, and a human agent from the Rank Math Support team will assist you further. Thank you for raising this concern!

    Sources:
    Why Are Posts Redirecting to www or Non-www Incorrectly?

    Hi,
    these codes worked for a day, now the problem is back. The redirect doesn’t work anymore. Why?

    Hello,

    Thank you for your query and we are so sorry about the trouble this must have caused.

    We checked the affected URLs and they seem to be redirected already although they are not redirected by our plugin:

    Rank Math support

    If that wasn’t it, please share the redirection rule you created in our plugin so we can take a closer look. We checked your redirection rules and we can’t find a matching source URL for the URLs you shared in this ticket.

    Looking forward to helping you.

    Hi, I added the rules in the htaccess file, while I didn’t add anything on your plugin. I don’t think there are actually two redirects of the same URL.

    Hello,

    Since you have added the redirection rule to your .htaccess file, you do not need to add the rule again via Rank Math. As we shared earlier, the rules are working and the URLs are redirecting correctly.

    Don’t hesitate to let us know if you need help with anything else.

    Hi, I have not added any rules in Rank Math. The only rules are in the htaccess file, but it doesn’t seem to work. I’m also attaching a screenshot that shows that the rules on Rank Math have not been created
    No redirect

    Hello,

    We can see the redirections added on Rank Math are working properly:

    However, please note that in order to redirect the URLs with query parameter, you’ll have to use the following filter on your website:

    add_filter( 'rank_math/redirection/add_query_string', '__return_false' );
    

    Here’s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Please note that this filter will only work if the redirections are added in Rank Math, not in the .htaccess file.

    Hope that helps and please don’t hesitate to let us know if you have any other questions.
     
    Thank you.

    Hi,
    I still haven’t solved it 🙁
    In the htaccess file I have this:

    # BEGIN WordPress
    # Le direttive (linee) tra "BEGIN WordPress" e "END WordPress" sono
    # generate dinamicamente, e dovrebbero essere modificate solo tramite i filtri di WordPress.
    # Ogni modifica alle direttive tra questi marcatori verrĂ  sovrascritta.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteRule ^en/wp-login.php /wp-login.php [QSA,L]
    RewriteRule ^it/wp-login.php /wp-login.php [QSA,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php [L]
    
    </IfModule>
    
    # END WordPress
    RewriteEngine On
    RewriteCond %{QUERY_STRING} option=com_content&view=article&id=1247 [OR]
    RewriteCond %{QUERY_STRING} option=com_content&view=article&id=1224 [OR]
    RewriteCond %{QUERY_STRING} option=com_content&view=article&id=1226 [OR]
    RewriteCond %{QUERY_STRING} option=com_content&view=article&id=1253
    RewriteRule ^index.php$ https://www.archeolibri.com/video/ [R=301,L]

    I have not added any more redirects on RANK Math.
    I disabled
    add_filter( 'rank_math/redirection/add_query_string', '__return_false' );

    If I type:
    http://www.archeolibri.com/index.php?option=com_content&view=article&id=1226
    the URL redirects to the Homepage and instead should go to the Video page

    Hello,

    We deeply apologize for the unexpected delay in response. Your previous reply seems to have been stuck in our drafts section for some reason.

    We checked the page you’ve shared and we can see it has multiple redirections and at the end, it is getting redirected to https://www.archeolibri.com/video/il-foro-romano/ page. However, this redirections are not done by the Rank Math plugin.

    Please note that we can only assist you if the redirections are added to the Rank Math Redirection module. If you’re using the .htaccess file then we suggest you get in touch with your hosting provider as they are in a better position to assist you on this.

    Hope that helps and please don’t hesitate to let us know if you have any other questions.
     
    Thank you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 9 replies - 1 through 9 (of 9 total)

The ticket ‘Redirect QUERY_STRING’ is closed to new replies.