0

I want to prevent general access to my css files so I want to know if there is a way to redirect the browser if the user tries to access /graphics/style/*.css using .htaccess since one can't put a redirect rule in a css file?? the css file would be written on page load, and deleted on session end but i need to prevent the css file from being viewed during a session.

Is it possible to do allow access only from server??

  • 3
    exactly how do you propose telling apart a user hitting the css to "view" it, v.s. a user hitting the css so the page they're loading can be rendered properly? Your only practical choice is to check the http referer, and since referers are essentially useless as far as reliability goes, you effectively CAN'T tell the two hits apart. and besides, since they'll have loaded the css to render your page properly, they'll ALREADY have a copy in their browser to poke around in. – Marc B Sep 05 '14 at 19:20

1 Answers1

0

In your .htaccess file and add this line:

Deny from  all

if you are planning to restrict to the complete folder create a htaccess in that folder and update above line, and it won't be accessible.

For redirect you can use:

 Redirect /folder/ 404.html

Edit: you can allow only server access the content by allowing the server ip to access the content and deny from others:

 order deny,allow
 deny from all
 allow from 111.222.333.444

Refer:

Deny all, allow only one IP through htaccess

deny direct access to a folder and file by htaccess

Deny access to one specific folder in .htaccess

Community
  • 1
  • 1
Coder anonymous
  • 917
  • 1
  • 8
  • 25