Redirect from root, to /public/, but use publics rules

Is this possible? I don’t want to setup a VHost since I use a grid server for live sites. I encounter this when trying to use Zend Framework, but it always makes me go to the /public directory. It basically makes all folder inaccessible except the public one, and the public folder is the one that appears at the site root.

folder1/
folder2/
folder3/
public/index.php
public/.htaccess
.htaccess

so when you go to www.site.com it loads www.site.com/public/index.php for every page request.

But the public/index.php would be required to use the public/.htaccess for rewriting the url.

JR,

What is the DocumentRoot of your website? Your discussion makes it seem as though public is the DocumentRoot (which would mean that all the other directories are not in your webspace).

If that’s not the case, you’ll need to show the .htaccess in the DocumentRoot as it’s apparently redirecting all to public/. We’ll look for RewriteBase in there (amongst other oddities).

Regards,

DK

Heya,

The document root would be: /html/
The /public/ directory is the actual directory the re-writing is happening in.

It is kind of like saying: Keep everything on the /html/ directory non-accessible to HTTP, yet allow the /public/ directory to be accessible and behave as the root.

Do you think this is a bad idea?

/html/.htaccess

RewriteEngine On
RewriteBase /public/

/html/public/.htaccess

Options +FollowSymLinks
AddDefaultCharset UTF-8

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
# This below probably needs a fix
RewriteCond %{REQUEST_URI} !^/public/

RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

JR,

The REAL way to do that is to change the DocumentRoot to /physical_path/public, not to wag some nonsense at the visitors.

Okay, now that I got that out of my system, I’d change your code as follows:

RewriteEngine On
# RewriteBase /public - RewriteBase is supposed to UNDO a mod_alias redirect, not to change directories
Options +FollowSymLinks
AddDefaultCharset UTF-8

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
# This below probably needs a fix
# If I understand you correctly ...
#RewriteCond %{REQUEST_URI} !^/public/
RewriteCond %{REQUEST_FILENAME) !^public/

RewriteRule ^(.*)$ /index.php?url=$1 [QSA,R=301,L]

Regards,

DK