Simple 301 Redirects
Can I exclude some clients from redirects? (2 posts)

  1. woozyg
    Posted 2 years ago #

    This plugin is nearly perfect for my use case. We changed our site domain from X to Y, but kept all the content at the same URIs. Wildcard redirects work great to transparently change the domain the users' browser.

    However, we want our Open Graph canonical URLs to stay the same, to keep our social media history (Facebook Likes, etc.) for existing content. To do that, crawlers need to be excluded from the redirects.

    Is there a way to add "excluded User Agents" such that requests with matching agents are NOT redirected, but instead see the page at the old URL?

    In our case we just have two domains pointing to the same WP instance, and want Facebook and others to continue to see old content at the old addresses, while actual humans see everything at the new domain, redirecting bookmarks to old content to the new domain.


  2. woozyg
    Posted 2 years ago #

    I added this at the top of the redirect() function, and it works great, but allowing for UI entry of the strings would be nice:

    function redirect() {
    			/* ignore bot user-agent values */
    			if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/(googlebot|facebookexternalhit|Twitterbot|twitterbot)/", $_SERVER['HTTP_USER_AGENT'])){

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Simple 301 Redirects
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.