Pointing Multiple Domains to Different Folders - zend-framework

I tried to my limit. Mod_rewrite had been such a nightmare. My last try is the code bellow and even with www.water.com working I could not make www.wind.com do the same.
In the mod_rewrite log what I get is www.wind.com (HTTP_HOST) being compared to www.water.com all the time. the rewrite never reaches the second group of lines. Someone perhaps know how to achieve that please?
RewriteEngine On
----------------------------------------------------------
RewriteCond %{HTTP_HOST} (www\.)?water\.com [NC]
RewriteCond %{REQUEST_URI} !^/zend/application/Water/ [NC]
# Excludes the redirection for files that physically exist ( -s); symbolic links ( -); and existing directories (-d).
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /water.php [NC,L]
----------------------------------------------------------
RewriteCond %{HTTP_HOST} (www\.)?wind\.com [NC]
RewriteCond %{REQUEST_URI} !^/zend/application/Wind/ [NC]
# Excludes the redirection for files that physically exist ( -s); symbolic links ( -); and existing directories (-d).
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /wind.php [NC,L]
----------------------------------------------------------

For the water group, you have two RewriteRules after your sequence of RewriteConds. The first RewriteRule is applied conditionally based upon the result of the RewriteConds.
But won't the second RewriteRule be applied to all remaining requests, even requests to the domain wind.com? Consider a request for:
http://wind.com/mycontroller/myaction
It will fail all the RewriteConds for water, but then get picked up by:
RewriteRule ^.*$ /water.php [NC,L]
Won't it?
In any case, it seems like this is better handled at the hosting level. Sounds like you want comepletely distinct ZF apps for each domain, each residing in its own folder, no cross-app sharing (except possibly external libs). In that case, just map the domains - at the hosting level - to their different folders.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteCond %{HTTP_HOST} (www\.)?water\.com [NC]
RewriteCond %{REQUEST_URI} !^/zend/application/Water/ [NC]
RewriteRule ^.*$ /water.php [NC,L]
RewriteCond %{HTTP_HOST} (www\.)?wind\.com [NC]
RewriteCond %{REQUEST_URI} !^/zend/application/Wind/ [NC]
RewriteRule ^.*$ /wind.php [NC,L]
This should work IMO.

Related

how to set baseurl while deployment in zend framework

this is my url
https://abc.com/project/projectfolder/public/
its shows 404 not found error
there is two .htacess one is under public folder and other is under projectfolder
now please let me know what to do
This is .htacess
Options +FollowSymLinks Options -MultiViews
RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond
%{REQUEST_FILENAME} -d RewriteRule ^.*$ – [NC,L] RewriteRule ^.*$/index.php [NC,L]
ommit the leading slash in last rule:
RewriteRule ^.*$ index.php [NC,L]
use the following,
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php

zend htaccess public php file

is there any way to access e.g. prolink.php file in zend /public directory by typing mydomain.com/prolink.php, and go to application in other cases (index.php)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
should I specify a route for that?
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^prolink.php$ public/prolink.php
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
If the request is for a file that exists already on the server, index.php isn't served.
put index.php file into the public folder
and put .htaccess in the root folder, witch contents
RewriteEngine On
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [NC,L]
Options -Indexes

Rewriting css file to controller's action

I would like to use .htaccess to rewrite http://localhost/css/file.css to http://localhost/css/generate
is it possible to do it?
it seems to not working. All I have is this .htaccess and Zend Controller css with action generate
if I go directly to localhost/css/generate I have css output but when I type localhost/css/file.css I get Not Found
this is my .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^/css/file\.css$ /css/generate
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Change your htaccess to this:
RewriteEngine On
RewriteRule ^/css/file\.css$ /css/generate [L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
the [L] means "last", which stops it running any subsequent rules if a match was found.
Yes. Place this in your top level .htaccess or httpd.conf and restart Apache.
RewriteEngine On
RewriteRule ^/css/file\.css$ /css/generate

.htaccess: how to redirect img,js.. from /www/ to /www/public/?

I have zend framework htaccess now:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ public/index.php [NC,L]
But I don't know how to redirect all "link" parameters like js, css, img.
Solution one:
Your web server should point to public/ directory, not to root directory of ZF project.
Solution two (better one I think):
Your web server points to ZF project directory, or even ZF project is in sub directory.
Like http://localhost/zf-project/ .
.htaccess in zf-project directory (right near public/, application/, library/ ...):
RewriteEngine On
RewriteRule ^(.*)$ public/$1?%{QUERY_STRING} [QSA,L]
.htaccess in public/ directory:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
And in application/configs/application.ini you set
resources.frontController.baseUrl = "/zf-project/"
Here is my .htaccess which is work perfect:
DirectoryIndex /public/index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^js/(.*)$ public/js/$1 [L]
RewriteRule ^img/(.*)$ public/img/$1 [L]
RewriteRule ^css/(.*)$ public/css/$1 [L]
RewriteRule ^.*$ public/index.php [NC,L]

Redirect all traffic but "beta" sub-domain to Splash screen (mod_rewrite)

I'd like to redirect all my traffic to my root domain, the root domain being a Splash screen. I'd like to do this ONLY when the %{HTTP_HOST} is not beta.example.(com|es|fr).
So I've tried the following in my .htaccess file, with no luck... (infinite loop... I guess it's not getting the REQUEST_URI condition, but cannot figure out why?? I've tried almost everything)
RewriteCond %{HTTP_HOST} !^beta\.example\.com$
RewriteCond %{HTTP_HOST} !^beta\.example\.es$
RewriteCond %{HTTP_HOST} !^beta\.example\.fr$
RewriteCond %{REQUEST_URI} !^/?$
RewriteRule ^.*$ / [NC,L,R=302]
At that point, I should have all my traffic but "beta" sub-domain redirected to the root domain. So now I'd like to Rewrite "backstage" the root domain with my Splash screen, following in the .htaccess file:
RewriteCond %{HTTP_HOST} !^beta\.example\.com$
RewriteCond %{HTTP_HOST} !^beta\.example\.es$
RewriteCond %{HTTP_HOST} !^beta\.example\.fr$
RewriteRule !\.(js|ico|txt|gif|jpg|png|css)$ splash.phtml [NC,L]
Note: I'm using the Zend Framework, so these rules are following in the .htaccess file:
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
I must say, I'm stuck.
thx in advance
#bsagols
This line from Zend is going to screw you up for sure.
RewriteRule ^.*$ index.php [NC,L]
You need to put your directives above this, if not above all of the Zend stuff. If I'm understanding you correctly, try this:
RewriteCond "%{HTTP_HOST}" "!^beta\.example\.(com|es|fr)$" [NC]
RewriteCond "%{REQUEST_URI}" "!\.(js|ico|txt|gif|jpg|png|css)$" [NC]
RewriteRule ".*" "/splash.phtml" [R=302,L]