-
Hi
Is there any option to add noindex, canonical tag or 301 redirections for “/?c=” included URL?
Thank You
Website: https://flipcashback.com
-
Hello,
Thank you for contacting Rank Math support, and sorry for any inconvenience that might have been caused due to that.
Please refer to this filter to set that specific page with a URL query parameter to
noindex
.add_filter( 'rank_math/frontend/robots', function( $robots ) { $url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; if(strpos($url, '?c=')) { $robots["index"] = 'noindex'; } return $robots; });
After this, the canonical tag should also be removed automatically.
Here’s our guide with regards to applying our filter to your website:
https://rankmath.com/kb/wordpress-hooks-actions-filters/Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Hi
Thanks for your reply.
For more details, The main page: is https://flipcashback.com
And duplicate pages are:
https://flipcashback.com/?c=USD
https://flipcashback.com/?c=EUR
https://flipcashback.com/?c=BDT
https://flipcashback.com/?c=INRThen how will the code be?
if(strpos($url, '?c=')) {
Hello,
The line
if(strpos($url, '?c=')) {
tests whether the current URL possesses the string ‘?c=’, if the URL does have the string it is set to noindex.Hope that helps. Please let us know if you have questions.
Hi
Is there any option to add 301 redirections for those types of URLs?
Hello,
Yes, you can use the “Contains” redirect type for those URLs if you wanted to redirect them.
Here’s a link for more information:
https://rankmath.com/kb/setting-up-redirections/#containsHope that helps.
Thank you.
Hi
I add the redirection rules “?c=” in contains and the destination URL is https://flipcashback.com but it’s not working.
Could you please check for it?
Thanks
Hello,
Can you please share a screenshot of the redirection you have created so we can check this issue further?
You may use this tool https://imgbb.com/ and share the URL here.
Thank you.
Hello,
Please try applying the following rule to see if that works for you.
Match Type: Regex Source URL: /?c=(.*) Destination URL: https://flipcashback.com
Let us know how it goes. Looking forward to helping you.
Thank you.
Hello,
The contains redirection rule you have created here should work fine: https://imgbb.com/4K2vHm8
However, our plugin appends the query parameter to the redirected URL and that’s why it seems like the redirection is not working. Please add the following filter to your site to fix the issue: https://rankmath.com/kb/filters-hooks-api-developer/#redirect-remove-query
Here is how to add a filter to your site: https://rankmath.com/kb/wordpress-hooks-actions-filters/
Hope that helps. Let us know if you need any other assistance.
Hello,
We might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.
Please do take a complete backup of your website before sharing the information with us.
It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:
https://wordpress.org/plugins/temporary-login-without-password/
You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):
https://wordpress.org/plugins/wp-security-audit-log/
Looking forward to helping you.
Thank you.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Hello,
I’ve added the following filter in Code Snippets plugin of your site and the redirection is now working perfectly fine.
function rm_redirection(){ $url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; if(strpos($url, '?c=')) { wp_redirect(home_url()); exit; } } add_action('init', 'rm_redirection');
Hope that helps, and please do not hesitate to let us know if you need our assistance with anything else.
Thank you.
The ticket ‘Add “noindex” tag for “/?c=” included URL’ is closed to new replies.