I am trying to hide a stylesheet so that when a user visits it directly from the browser, it would show a 404, but show correctly on my site. Is this possible? I am currently trying this with:
RewriteEngine On
Options +FollowSymLinks
RewriteRule ^/?wp-content/themes/mysteam/style.css$ /wp-content/themes/steam/stylesheet.css [L,NC]
Is there any way I can achieve this?
Thanks.
You cannot securely hide a css file from the client if you want to use it on at least 1 page.
You can use the referer header to redirect to a 404-page if it is not set, but:
You could set up a very smart system that would generate an unique id for every request, and would only show the css file if that id matches an id that is currently authorized to see that page, but:
Your stylesheet is requested from the browser to apply style to your text, and therefore it will always be possible to forge a request with that browser to see the contents of the file (or the output a file generates) or, more simple, by viewing the output when the browser needs it.
The syntax you are using is invalid. See the documentation for more information. The pattern cannot start with a
/
and it will not include the query string. Your rewriterule would look like:The first line will match the query string. The second line has a trailing
?
in the rewritten part to clear the original query string.