Eugene
Eugene

Reputation: 11270

how to emulate public dir with mod_rewrite

I keep my website files in /public/ directory.

So, for example, to access css file, if we point absolute html path, it would be

/public/css/reset.css.

I have /public/index.php file that handles every request. So, my main site API works fine.

Here's my simple .htaccess: (outside the public dir)

<IfModule mod_rewrite.c>
RewriteEngine On 
RewriteRule !\.(js|ico|gif|jpg|png|css|html)$ public/index.php
</IfModule>

How can I add mod_rewrite rules, so, when I ask mysite.com/css/reset.css I get mysite.com/public/css/reset.css (so, for other files too)

Upvotes: 0

Views: 190

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798536

RewriteCond -f public%{REQUEST_URI}
RewriteRule ^(.+)$ public/$1 [L]

Upvotes: 1

Related Questions