Topic: redirecting for certain files only
|

|
| Author |
|
lo0kash Newbie

Joined: 04 December 2007
Online Status: Offline Posts: 15
|
| Posted: 29 June 2010 at 6:24am | IP Logged
|
|
|
Hello,
I need to redirect all requests excluding css, js, jpg etc files to different domain, so I have:
RewriteCond Host: (?:www\.)?domain\.com RewriteRule (?!.*\.(?:css|jpg|gif|zip|js|png|jpeg|txt|pdf)).* http\://www.redirectdomain.com [I,RP,L]
This works ok for http://www.domain.com/robots.txt (stays on domain) but not for http://www.domain.com/robots.txta - it stays on domain.com and displays 404. Expected behaviour is that it should be redirected to www.redirectdomain.com I've tried to remove .* from the end of the rule but that didn't help. It works ok for http://www.domain.com/robots.test - requests is redirected to www.redirectdomain.com.
Thanks in advance
Lo0kash
|
| Back to Top |
|
| |
Anton Admin Group

Joined: 30 January 2007 Location: Ukraine
Online Status: Offline Posts: 10489
|
| Posted: 29 June 2010 at 9:28am | IP Logged
|
|
|
So you also want to account for misprints. Please try it like this:
RewriteCond Host: (?:www\.)?domain\.com
RewriteRule (?!.*\.(?:css|jpg|gif|zip|js|png|jpeg|txt|pdf).*).* http\://www.redirectdomain.com [I,RP]
__________________ Regards,
Anton
|
| Back to Top |
|
| |
lo0kash Newbie

Joined: 04 December 2007
Online Status: Offline Posts: 15
|
| Posted: 29 June 2010 at 9:47am | IP Logged
|
|
|
Thanks Anton,
/robots.txta still causes 404 being served from the original domain. Anyway, this is no longer a problem for me, thanks for your help.
|
| Back to Top |
|
| |
|
|
If you wish to post a reply to this topic you must first login
If you are not already registered you must first register
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum
|