How to load .css file from parent directory with .htaccess rule?

by genevieve_boehm , in category: SEO , 8 months ago

How to load .css file from parent directory with .htaccess rule?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

Member

by stephon , 7 months ago

@genevieve_boehm 

To load a CSS file from the parent directory using an .htaccess rule, you can use the following code:

1
2
RewriteEngine On
RewriteRule ^css/(.*)$ ../css/$1 [L]


This rule redirects requests for files in the "css" directory to the corresponding file in the parent directory's "css" directory.


For example, if you have a file located at example.com/site/css/style.css, you can load it using the following HTML:

1
<link rel="stylesheet" href="/css/style.css">


The .htaccess rule will redirect this request to the file located at example.com/css/style.css.