0

I am trying to prevent the direct access to my website resources using htaccess.My website is orlandojoes.co.uk/clouds which is a subfolder.But if i enter orlandojoes.co.uk/clouds/css/style.css in the address bar i can see them.But i want to prevent seeking them and redirect to index.html.

I am trying:

RewriteEngine on 
RewriteCond %{HTTP_REFERER} !^http://(www\.)?orlandojoes.co.uk\.ltd [NC] 
RewriteCond %{HTTP_REFERER} !^http://(www\.)?orlandojoes.co.uk\.ltd.*$ [NC] 
RewriteRule \.(gif|jpg|js|txt|css)$ /HeyManYouHaveComeToAwrongPlace;) [L]

But it blocks all.Even in index.html page show only markups not with stylings. What can be a solve?

9
  • Why do you want to block direct access? Even if you succeed, the user can still view the files after loading whichever of your html pages use those resources. Commented Jul 12, 2015 at 4:45
  • 2
    this has nothing to do with html css or javascript Commented Jul 12, 2015 at 4:48
  • looking at the ReqriteCond lines, you'd block requests unless they came from www.orlandojoes?co?uk.ltd - where ? is any character - I think you need to check the RewriteCond syntax Commented Jul 12, 2015 at 4:55
  • @nnnnnn its not a problm if they can see which resources i am using... such as i am using style.css but i want them not to access into the file Commented Jul 12, 2015 at 4:56
  • 1
    There is no way to prevent the user seeing the contents of your css file once the browser has loaded an html page that uses that css file. Commented Jul 12, 2015 at 5:13

1 Answer 1

2

Simple Answer: You cannot do that.

If you want the browser to apply CSS to your webpage and execute JavaScript, then you cannot prevent it from the users.

If you manage to block the CSS and JS files, then how will the browser access them?

The most you can do is minify or uglify, which will just make it difficult (not impossible) to view your CSS and JavaScript.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.