Forum Moderators: phranque

Message Too Old, No Replies

.htaccess rewrite file but redirect everything else to domain

redirect all to external domain except one file

         

johnhamman

1:23 am on Aug 28, 2008 (gmt 0)

10+ Year Member



Hi all,
I want to achieve 2 things here.

First I want to rewrite a dynamic file like this
www.domain.com/a/abc-abc.js really pulls www.domain.com/files/somefile.php

and then I also want every other request that is not for www.domain.com/a/abc-abc.js to redirect to www.domain2.com

so
www.domain.com/a/abc-abc.js -> /files/somefile.php
www.domain.com/a/xyz-xyz.js -> /files/somefile.php
www.domain.com -> www.domain2.com
www.domain.com/a/-> www.domain2.com
www.domain.com/a/abD123.js -> www.domain.com

I have

RewriteRule ^a/+([a-z0-9]{3})-+([a-z0-9]{3}).js /files/somefile.php
and that works, but I dont know how to do that AND redirect all non calls to the js file to redirect to another domain!

Can someone help?

johnhamman

1:51 am on Aug 28, 2008 (gmt 0)

10+ Year Member



Also, is it possible to deny direct calls to www.domain.com/files/somefile.php

jdMorgan

3:56 pm on Aug 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Please check out the resources cited in our forum charter [webmasterworld.com] and the threads in our forum library [webmasterworld.com] to help you get started. Reading the charter in particular will help you get the most from this forum.

Thanks,
Jim