• My client’s organization recently underwent a name change so that forced a number of changes to their website. This included not only a new domain name but changes to the site’s directory structure naming.

    All but one of the rewrites in the htaccess file are working correctly. For some reason, the rewrite for URLs to the uploads directories doesn’t swap the old domain for the new. It’s ok for now since their old domain is still working but when it lapses links in the wild will break. Seeing as it’s using the same method as the others that *do* work, I’m at a loss to figure out how to solve this problem.

    Here are the specific rewrite rules I have in place:

    #ANYTHING IN THE OLD ABOUT DIRECTORY GETS BUMPED BACK TO THE NEW TOP-LEVEL ABOUT PAGE
    RewriteRule ^about-organizationold/?(.*)? http://www.newdomain.tld/about-organizationnew/ [R=301,NC,L]
    
    #OLD LINKS TO ANY MEMBER PROFILES STAY INTACT
    RewriteRule ^organizationold-membership/member-profile/?(.*)? http://www.domain.tld/membership/member-profile/$1 [R=301,NC,L]
    
    #USED AFTER THE SPECIFIC RULE ABOVE TO COVER ANY OTHER OLD PAGES IN THE MEMBERSHIP DIRECTORY TO GET BUMPED TO THE TOP-LEVEL MEMBERSHIP PAGE
    RewriteRule ^organizationold-membership/?(.*)? http://www.domain.tld/membership/ [R=301,NC,L]
    
    #BUMPS OLD PAGES TO TOP LEVEL OF CONFERENCE SECTION
    RewriteRule ^organizationold-conference/?(.*)? http://www.domain.tld/organizationnew-conference/ [R=301,NC,L]
    
    #SIMPLIFIED BLOG URL
    RewriteRule ^organizationold-blog/?(.*)? http://www.domain.tld/blog/ [R=301,NC,L]
    
    #REWRITE SHOULD SWAP THE OLD DOMAIN FOR THE NEW AND MAINTAIN THE STRING TO THE SPECIFIC FILE BUT IT ONLY DOES THE LATTER
    RewriteRule ^subdir/wp-content/uploads/?(.*)? http://www.domain.tld/subdir/wp-content/uploads/$1 [R=301,NC,L]
    
    #REWRITE TO COVER OLD DOMAIN TO NEW AND AVOID CANONICAL ISSUES
    RewriteEngine on
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^olddomain.tld$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^www.olddomain.tld$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^.newdomain.tld$ [NC]
    RewriteRule (.*) http://www.newdomain.tld/$1 [R=301,L]

    Any insight?

  • The topic ‘Domain Rewrite Rules Working Except One for the Uploads Directory’ is closed to new replies.