WordPress.org

Support

Support » Plugins and Hacks » Simple 301 Redirects » Can I exclude some clients from redirects?

Can I exclude some clients from redirects?

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

    http://wordpress.org/plugins/simple-301-redirects/

Viewing 1 replies (of 1 total)
  • 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'])){
    				return;
    			}
    ...
Viewing 1 replies (of 1 total)
  • The topic ‘Can I exclude some clients from redirects?’ is closed to new replies.
Skip to toolbar