Zend Framework Error : The requested URL was not found - zend-framework

I'm trying to set up my zend framework application on this host but I'm getting a Requested URL not found error:
The application isn't at the root level i.e its in a folder like: www.mysite.com/zendapp/public
The error says that it can't locate the index.php file even though the url given in the erro message is correct.
Is this an htaccess issue? The homepage opens fine - the issue arises when I click on any link. Here is my htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
URL rewrite is enabled on the host.

Two things to check:
RewriteBase in your .htaccess
baseUrl property of the front controller

Related

Zend Framework - do not treat /public/directory as a controller

Is it possible to request a directory over http in the Zend /public/ directory without it being treated as a controller?
Eg, I have a directory, /public/facebook/ that contains facebook app data but Zend is (as default expected behaviour) giving "facebook controller missing" error when I request http://mysite.com/facebook.
This is because the default RewriteRules provided with Zend are redirecting all requests to the Zend Framework Bootstrapper (index.php).
The best thing to do, IMHO, is to add an exception to this Rule. Then there's more than one way to do it. You could use RewriteCond (and for example avoid the general redirect for existing directory or files in /public). But you could maybe filter it in the RewriteRule expression as well. This is an example with exception in the RewritreRule, so withoutt RewriteCond:
RewriteRule !(public/facebook/(.*\.php))|(public/(.*\.pdf))|(externalauthent\.php)|(favicon.ico)|(images/(.*\.(ico|gif|jpg|png|bmp|JPG|JPEG|BMP|GIF|PNG)))|(css/(.*\.css))|(js/(.*\.*))$ /index.php [L]
If you have content in this url, ZF don't try to found facebook controller, You need add a folder named facebook, and a file index.php into this folder
This work for me:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteCond %{REQUEST_URI} !^/public_directory_name
RewriteRule ^.*$ index.php [NC,L]
Just replace 'public_directory_name' with the name of the directory you don't want Zend to treat as a controller.
Answered in a different worded question: htaccess - do not rewrite in this case

Zend application problem on iis6

When I'm passing the URL like http://localhost/home/index/index in my application I'm getting the module=>default, controller=>index, action=>index. Whatever may be the URL i'm getting the same thing. I'm running the application on IIS6 in windows 2003 platform. If i'm overriding the module as 'home' in Zend_Controller_Request_Abstract=>getModuleName() method then my home page is coming fine. I'm unable to get where exactly it is overriding the value to 'default','index','index'. Can any one help me?
Thanks in advance
Update:
The problem is with $_SERVER['HTTP_X_REWRITE_URL']. I'm getting the same URI into both $_SERVER['HTTP_X_REWRITE_URL'] and $_SERVER['REQUEST_URI'] like /public_mvc/index.php. I'm not overriding the value of $_SERVER['HTTP_X_REWRITE_URL'] anywhere in my code. My .htaccess code is like this.
RewriteEngine on
RewriteRule ^admin-mvc(.*)$ public_mvc/admin.php [L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^[\w/\%](?:.(?!(?:js|ico|gif|jpg|png|css|html)$)[\w\%]$)? public_mvc/index.php [I]
RewriteRule ^$ /home [r=301,nc]
I'm using ISAPI Rewrite 3 for URL Rewriting.
this is how Zend Framework handles the "default" module.
You can access your root path like this:
domain.tld/
domain.tld/index
domain.tld/index/index
domain.tld/default/index/index
all request will result in
module: default
controller: index
action: index
Update 1:
Probably there is a static route for module home configured
http://framework.zend.com/manual/en/zend.controller.router.html#zend.controller.router.routes.static
which sends requests for
/home/index/index
to
/default/index/index
Update 2:
Make sure you have Isapi_Rewrite installed as indicated here (search for IIS):
http://framework.zend.com/manual/en/zend.controller.router.html
Update 3:
Add this rewirte rule to your .htaccess (as indicated in Zend article of Update 2):
RewriteRule ^[\w/\%]*(?:\.(?!(?:js|ico|gif|jpg|png|css|html)$)[\w\%]*$)? /index.php [I]
Update 4:
Try the following code in your .htaccess (it is the recommendation from Zend article of Update 2)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
RewriteRule ^[\w/\%]*(?:\.(?!(?:js|ico|gif|jpg|png|css|html)$)[\w\%]*$)? /index.php [I]
If this does not work, I'm not sure what the solution is. I'm not using IIS and not familiar with the particularities there...

zend framework deployment in server

I have a server, where I have uploaded my work in zend framework(in a subdomain). the folder name is 'visit'.
So, When I go to: http://mysitename.com/visit, it shows a directory structure:
Parent Directory
application/
docs/
library/
nbproject/
public/
tests/
But when I go to: http://mysitename.com/visit/public, i get the index page of my project.
But I want to get my index page , when I type: http://mysitename.com/visit
can you please give me the correct htaccess it need?
Also, these other approaches to deploying in shared hosting can help:
Zend Framework on shared hosting
http://www.alberton.info/zend_framework_mod_rewrite_shared_hosting.html
http://akrabat.com/zend-framework/zend-framework-on-a-shared-host/
http://www.ttech.it/en/article/2010/03/zend-framework-all-projects-files-on-document-root/
In particular, an answer by tharkun led me to write it up in more detail in a blog post.
You can do this with the following rule set, which is in part a partially modified version of the one described in the documentation.
.htaccess file in /visit:
RewriteEngine on
# Guard against people visiting /public/ directly
RewriteCond %{THE_REQUEST} ^[A-Z]\s/visit/public/
RewriteRule ^public/(.*)$ /visit/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
# Make sure we've rewritten to the ./public/ directory already
RewriteCond $0 ^public/
RewriteRule ^.*$ - [NC,L]
# The index file is now at /visit/public/index.php
RewriteRule ^.*$ /visit/public/index.php [NC,L]

Zend and modrewrite not working together properly

I'm setting up a Zend application, and went through the basic steps of setting up modrewrite on my development station, and writing an .htaccess file (shown below). Now, when I go to the root of my project, Zend works properly, calling the controller and displaying the appropriate page.
However, when I call any controller, I would expect it to redirect to the same index.php file, which would in turn direct it to the appropriate controller and action (e.g. myurl/controller/action would be read by myurl/index.php which would then redirect to the action appropriately).
I suspect that the issue is somehow related to how I've set up my .htaccess file, since calling the base url does work properly. But I haven't been able to figure out what's wrong. Does anyone have a suggestion?
Options +FollowSymLinks
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]
RewriteRule ^(.*)/(.*)/(.*)$ index.php [NC,L]
RewriteRule ^(.*)/(.*)/(.*)/(.*)$ index.php [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Okay, here's what it was.
My DOCUMENT_ROOT is set to /var/www while my application is running out of /var/www/app1 with everything set up in there. Because of the line RewriteBase / it was redirecting to the DOCUMENT_ROOT instead of to the APPLICATION_ROOT. I fixed it by changing that line to:
RewriteBase /app1
and now everything works perfectly.

ISAPI ZEND url rewrite adding extra "/index.php/" into url

We recently reinstalled our web site on our server, the sys admin says it is an exact rebuild, and it indeed looks to me that it is, but there is something different going on. I did not originally develop the site, and those who did are no longer available.
urls for the admin site are now
//admin.site.com/index.php/schedules
and used to be, and should be
//admin.site.com/schedules
The extra index.php is getting inserted in the url. But all links within the admin site do not include the index.php so they do not work. If you insert the index.php into any url, it works. Where did this index.php come from and how do I eliminate it from the rewrite rules so the links will work.
This is what my httpd.conf file reads:
# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.56
# turn on rewriting RewriteEngine On RewriteBase /
# for all files not found in the file system,
# reroute to "index.php" bootstrap script,
# keeping the query string intact.
RewriteCond %{HTTP_HOST} ^admin.site.com$
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteCond %{HTTP_HOST} ^admin.site.com$
RewriteRule ^.*$ index.php [NC,L]
Thank you! Any help would be greatly appreciated.
You need to implement and enable ApacheModrewrite. And then put a .htaccess file in your admin.site.com folder
Its content will be :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]