Home Htaccess - Rewrite CSS src with 2 htaccess in different directory levels
Reply: 0

Htaccess - Rewrite CSS src with 2 htaccess in different directory levels

user1411
1#
user1411 Published in May 20, 2018, 10:13 am

I have a particular case envolving URL rewrite with 2 .htaccess files. I'm trying to rewrite my css path using htaccess. My real URL is 'localhost/Dev/Projects/redirector/index.php', but in my first htaccess I rewrite to 'localhost/redirect'. If I use the first URL, my css works. But if I use the second, it doesn't work.

That's my structure:

- htdocs (root)
- index.html
- .htaccess (1)
    - Dev
       - Projects
           - redirector
               - css
                  - style.css
               - index.php
               - .htaccess (2)

Htaccess (1)

RewriteEngine on
RewriteRule ^(redirector)/(.*)  /Dev/Projects/redirector/index.php?p=$1;r=$2

index.php

<html>
<head>
     <link rel="stylesheet" type="text/css" href="style">
</head>
<body>
     <p>This is in red?</p>
</body>
</html>

style.css

p{
   color: red;
}

Htaccess (2)

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule style css/style.css

I don't want use absolute path because I want hide my directory structure. There's a way to do that when my second htaccess is in a subdirectory? Because I want keep a htaccess for each project.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.298755 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO