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

by jaycee_rowe , in category: SEO , 6 months ago

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

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

Member

by virginie , 6 months 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.