Search code examples
cssresourcesstylesheet

How is it possible for a website to hide page style sheets?


A moment ago, I was reading a CSS Tricks tutorial on styling the scroll bar. I navigated to the demo, and proceeded to view the page's source styles in Dev Tools, however I found the CSS file listed to be blank.


enter image description here


I moved to the page's source, and clicked on the link to the style sheet, in the header, and to my surprise, I was shown this:


enter image description here


I'm curious to know how it's possible to serve the browser a proper style-sheet, which it utilizes to style the page, and then serve the client a spoof resource.


  1. How is this done?

  2. If I wanted to look at this file, could I do it? How?

  3. Can this be done for other resources, such as JavaScript?


Solution

  • I assume he's sending the user to a chosen page whenever they try to access any .css filetype. This can be done by editing the .htaccess with something like this..

    RewriteEngine On
    
    RewriteRule ^.*\.css$ /custompage.html [R=301,L]
    

    You can still access the CSS just not directly, try looking at it using the developer tools of your browser.