CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Apache configuration (http://www.codingforums.com/forumdisplay.php?f=69)
-   -   Redirect example.com/robots.txt to example2.com/example/robots.txt (http://www.codingforums.com/showthread.php?t=196698)

ahayzen 05-24-2010 01:11 PM

Redirect example.com/robots.txt to example2.com/example/robots.txt
 
Hi I have a parked domain (example.com) and I am trying to redirect them to the primary address (example2.com) but within a folder.

So requests for
example.com/robots.txt
would go to
example2.com/example/robots.txt

I also need it to work with and without www.

The current code i have got is
Code:

RewriteCond %{HTTP_HOST} ^example.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteCond %{REQUEST_URI} ^\/robots\.txt
RewriteRule ^/?$ "http\:\/\/www\.example2\.com\/example\/robots\.txt" [R=301,L]

but it doesn't work.

Thanks in advance

Andy

ahayzen 05-24-2010 01:15 PM

Or if you can work out a way of redirecting
example.com/*
to
example2.com/example/*

That would be even better.

Andy

abduraooft 05-24-2010 01:45 PM

I don't think, you can place the robots.txt file of a domain under another one.

ahayzen 05-24-2010 01:48 PM

After a bit of head scratching and lots of reading I've done it
Code:

RewriteCond %{HTTP_HOST} example.com
RewriteCond %{REQUEST_URI} !^/example
RewriteRule ^(.*)$ example/$1 [L]


ahayzen 05-24-2010 01:52 PM

This thread can be marked as Resolved


All times are GMT +1. The time now is 06:27 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.