Forum Moderators: phranque

Message Too Old, No Replies

redirect any attempts to view js files

         

grief

9:37 pm on Jul 7, 2005 (gmt 0)

10+ Year Member



In my .htaccess im trying to redirect
any attempts to view js files in a browser
this is what i have so far and i cant
quite get it to work for me. any help
would be appreciated

RewriteEngine on
RewriteCond %{REQUEST_FILENAME}.js -f
RewriteRule ^(.*)$ [mysite.net...] [L]

-regards

grief

1:50 am on Jul 8, 2005 (gmt 0)

10+ Year Member



I seemed to have got it working this way. at first it would work but it would hide js files from people and
my php couldnt see them so i decided to try checking for a referer being empty. im very new at this so if this looks wrong im sorry

RewriteEngine on
rewritecond %{http_referer}!. [NC,OR]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mysite.net/.*$
RewriteRule \.(js¦css)$ - [F]

jdMorgan

2:20 am on Jul 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd suggest:

RewriteEngine on
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite\.net
RewriteRule \.(js¦css)$ - [F]

Be aware that this will block CSS (and JS) for people trying to view your pages in Google's cache (and others), and your page will appear to be badly-formatted.

Replace the broken pipe "¦" character with a solid pipe character from your keyboard before trying to use code posted on WebmasterWorld -- posting on this forum modifies that character.

Jim

grief

4:35 am on Jul 8, 2005 (gmt 0)

10+ Year Member



Rock on man!
I'm not to worried about the google cache i
try to keep my site off google and other
using robots.txt and all of this.

thank you for helping