WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. woozyg
    Member
    Posted 8 months 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.

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

  2. woozyg
    Member
    Posted 8 months 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'])){
    				return;
    			}
    ...

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.