Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using .htaccess to bypass Zend Framework and run different framework in sub directory

I'm trying to run a non-Zend php application within a sub directory of a Zend site. I'd like to bypass the Zend application for all files within the sub directory '/branches' in .htaccess. So far none of the solutions I've found have worked. Here is the current .htaccess file:

RewriteEngine on
RewriteBase /

# WWW Resolve
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^web/content/(.*)$ http://www.domain.com/$1 [R=301,L]

# Eliminate Trailing Slash
RewriteRule web/content/(.+)/$ http://www.domain.com/$1 [R=301,L]

# Route Requests
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

Can this even accomplished in .htaccess?

like image 743
Ryan Linton Avatar asked Nov 03 '22 11:11

Ryan Linton


1 Answers

You currently have:

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

This makes no sense, as the RewriteCond you have specified to basically not do anything for actual files, directories, and symlinks will never work. This is because, that RewriteRule is followed immediately by the rule to rewrite EVERYTHING to index.php.

If your intent is to direct everything that is not a request to a real directory of file to index.php, you should have something like this:

RewriteCond %{REQUEST_FILENAME} -s
RewriteCond %{REQUEST_FILENAME} -l
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ index.php [NC,L]

And to add the special case of ignoring /branches just add one condition like this:

RewriteCond %{REQUEST_FILENAME} -s
RewriteCond %{REQUEST_FILENAME} -l
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME} !^branches/
RewriteRule ^.*$ index.php [NC,L]
like image 172
Mike Brant Avatar answered Nov 10 '22 14:11

Mike Brant