MrMadBacon MrMadBacon - 1 year ago 116
Apache Configuration Question

How to redirect all requests with .htaccess

So, here's what my folder structure is like:


I want that when I type
the request go to the
file but don't display the
And if I go to\app
it goes to
but only shows\app

Is that possible with .htaccess?

Answer Source

In your site root .htaccess you can use this:

DirectoryIndex index.php
RewriteEngine On

# add trailing slash in front of directories
RewriteCond %{DOCUMENT_ROOT}/public/$1 -d
RewriteRule ^(.*?[^/])$ %{REQUEST_URI}/ [L,R=301,NE]

# internally forward to /public/...
RewriteRule !^public/ public%{REQUEST_URI} [L,NC]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download