how to set baseurl while deployment in zend framework - 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

Related

codeigniter 3 .htaccess file is not working

im using codeigniter 3.1.9 and XAMP. i try eevrything but is not working
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Please try this
RewriteEngine on
RewriteBase /foldername/
# RewriteCond $1 !^(index\.php)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Note : If you put ".htaccess" inside a folder, don't forget to add RewriteBase.

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

Pointing Multiple Domains to Different Folders

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.

.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]