.htaccessiishelicontech

Redirect a specifc but wild card * URL (with folder(s)) to new domain (same structure)


I need to redirect a specific URL (with structure) to a the same URL(s) using a new domain, but not other URLS.

domainA.com/company/careers*

domainB.com/company/careers*

The reason for this is a 3rd party vendor supplying a jquery based iframe app that perfoms a referrer check before loading.

I realize there is a bigger seo/duplicate content issue that needs to be addressed, but there is a lot of additional work that needs to happen before domainA.com is fully redirected to domainB.com so for now, Its only the "career" section.

The site is using IIS6 with HeliconTech's ISAP ReWrite3

http://www.helicontech.com/isapi_rewrite/doc/introduct.htm

Current Rules:

# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.59

<VirtualHost www.domainA.com www.domainB.com> 

RewriteEngine On 

#RewriteBase /
#RewriteRule ^pubs/(.+)\.pdf$ /404/?pub=$1.pdf [NC,R=301,L]

# Send away some bots
RewriteCond %{HTTP:User-Agent} (?:YodaoBot|Yeti|ZmEu|Morfeus\Scanner) [NC] 
RewriteRule .? - [F]

# Ignore dirctories from FarCry Friendly URL processing
RewriteCond %{REQUEST_URI} !(^/measureone|^/blog|^/demo|^/_dev)($|/) 
RewriteRule ^([a-zA-Z0-9\/\-\%:\[\]\{\}\|\;\<\>\?\,\*\!\@\#\$\ \(\)\^_`~]*)$ /index.cfm?furl=$1 [L,PT,QSA] 

RewriteCond %{REQUEST_URI} ^/company/careers [NC]
RewriteRule ^company/careers/?(.*)$ http://www.domainname.com/company/careers/$1 [R=301,L]

# Allow CFFileServlet requests
RewriteCond %{REQUEST_URI} !(?i)^[\\/]CFFileServlet


RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /blog/index.php [L]

</VirtualHost> 

<VirtualHost blog.domainA.com> 

RewriteEngine On 

#redirect old blog.domainA.com/* posts to www.domainB.com/blog/*
RewriteCond %{HTTP_HOST} ^blog.domainA\.com [nc]
RewriteRule (.*) http://www.domainB.com/blog$1 [R=301,L]


</VirtualHost> 

Solution

  • It seems that "RewriteBase /blog/" line corrupts your "careers" rule as it implies that the request should be domainA.com/blog/company/careers*

    Please consider having it like this:

    <VirtualHost www.domainA.com www.domainB.com> 
    
    RewriteEngine On 
    RewriteBase /
    #RewriteRule ^pubs/(.+)\.pdf$ /404/?pub=$1.pdf [NC,R=301,L]
    
    # Send away some bots
    RewriteCond %{HTTP:User-Agent} (?:YodaoBot|Yeti|ZmEu|Morfeus\Fucking\Scanner) [NC] 
    RewriteRule .? - [F]
    
    # Ignore dirctories from FarCry Friendly URL processing
    RewriteCond %{REQUEST_URI} !(^/measureone|^/blog|^/demo|^/_dev)($|/) 
    RewriteRule ^([a-zA-Z0-9\/\-\%:\[\]\{\}\|\;\<\>\?\,\*\!\@\#\$\ \(\)\^_`~]*)$ /index.cfm?furl=$1 [L,PT,QSA] 
    
    RewriteCond %{REQUEST_URI} ^/company/careers [NC]
    RewriteRule ^company/careers/?(.*)$ http://www.domainname.com/company/careers/$1 [R=301,L]
    
    # Allow CFFileServlet requests
    RewriteCond %{REQUEST_URI} !(?i)^[\\/]CFFileServlet
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^blog/.* /blog/index.php [L]
    
    </VirtualHost> 
    

    If you still have issues, enable logging in httpd.conf by putting

    RewriteLogLevel 9
    

    and check how your request is processed in rewrite.log.