htmlcssmod-rewritebase-tag

hide folder or path css js files with httacces


i'm trying this:

.htaccess

# BEGIN 
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /proyect/rewrite/

RewriteRule ^css/(.*) /proyect/rewrite/wp-content/$1 

</IfModule>
# END 

html file

<!DOCTYPE html>
<html>
<head>

<!-- H1 COLOR BLUE -->
<link href="http://localhost/proyect/rewrite/wp-content/css/customjd.css" rel="stylesheet" type="text/css" > 

<!-- H1 COLOR RED-->
<base  href="/customjd.css" >

</head>

<body>

<h1>hello world!</h1>

</body>

</html>

but nothing happens. h1 don't change it's color.

PD: inside folder wp-content exists customjd.css h1 color red.


Solution

  • Edit the htaccess code to:

    RewriteEngine On
    
    RewriteRule ^(css/.*\.css)$ /proyect/rewrite/wp-content/$1
    

    Change the HTML code to:

    <!DOCTYPE html>
    <html>
    <head>
      <base href="/proyect/rewrite/">
      <link href="css/customjd.css" rel="stylesheet" type="text/css">
    </head>
    <body>
      <h1>hello world!</h1>
    </body>
    </html>
    

    where the CSS code inside customjd.css is:

    h1 {
      color: red;
    }