1

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> 

2 Answers2

1

Just check to see if the request starts with /company/careers

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/company/careers [NC]
RwriteRule ^company/careers/?(.*)$ http://domainB.com/company/careers/$1 [R=301,L]

See if that works for you.

Panama Jack
  • 24,158
  • 10
  • 63
  • 95
  • Sure seems like it should but it doesn't.. I should also mention we have a rule above this that deals with friendly urls for our CMS. – Mighty Aswell Feb 12 '15 at 22:46
  • Always put all your info including current htaccess rules in the question. Please edit your question and provide all of the info. There is no way for us to know what all rules or what you are doing on your site. – Panama Jack Feb 12 '15 at 22:50
  • @MightyAswell It appears you have it in the vhost file and not htaccess. So add a `/` at the beginning of the rewrite rule before company. `^/company/careers/?(.*)$` also don't forget to reload apache. – Panama Jack Feb 12 '15 at 23:04
  • the syntax should be the same as an apache .htaccess file, but the technology is ISAPI ReWrite... an IIS module [ISAPI ReWrite Compatibility](http://www.helicontech.com/isapi_rewrite/doc/compatibility.htm) – Mighty Aswell Feb 12 '15 at 23:39
1

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.

TonyCool
  • 1,004
  • 1
  • 6
  • 5