0

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)

Larry Foobar
  • 11,092
  • 15
  • 56
  • 89

1 Answers1

1
RewriteCond -f public%{REQUEST_URI}
RewriteRule ^(.+)$ public/$1 [L]
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
  • I've tried this. It doesn't work ;( When I open `mysite.com` it opens directory of my site – Larry Foobar Mar 04 '12 at 10:36
  • it works only if I point `http://mysite.com/public/$1` instead of `public/$1`, and works without RewriteCond. And it's possible to not redirect directly? I mean not to show /public/ path in url? – Larry Foobar Mar 04 '12 at 10:49