How to prevent viewing of css file on browser using .htaccess?

by jaycee_rowe , in category: SEO , a year ago

How to prevent viewing of css file on browser using .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

Member

by virginie , a year ago

@jaycee_rowe 

To prevent viewing of CSS files on the browser using .htaccess, you can place a directive in your .htaccess file that restricts access to the files with a specific extension. Here's how:

  1. Create or open the .htaccess file in the root directory of your website.
  2. Add the following code to the .htaccess file: This code specifies that all files with the .css extension will be denied access when requested by a browser.
  3. Save the .htaccess file.


Now, if someone tries to directly access a CSS file in the browser by entering the URL, they will see a "403 Forbidden" error message instead of viewing the file.

Related Threads:

How to prevent viewing of css file on browser using .htaccess?
What Are Effective Methods to Prevent Caching in Html?
How to load .css file from parent directory with .htaccess rule?
How to Integrate Vue.js with Existing React or Angular Projects Without Conflicts?
How to add .html using .htaccess file?
How to remove file name from url using .htaccess?