简体   繁体   中英

Zend App is not working after deployment. Can access only the homepage

I can access the homepage and can get the data from the database. There everything seems OK. But when I try to go to another page from my application I am redirected to 404 error page . The URL which is showing at the bottom left corner on my browser when hover the link seems ok. It is as should be.

I tried to change the .htaccess file on the server from:

# Do not remove this line, otherwise mod_rewrite rules will stop working

RewriteBase /

To:

# Do not remove this line, otherwise mod_rewrite rules will stop working

RewriteBase /

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

But it fails again. Tried different combinations. For example change RewriteBase / to RewriteBase /projectname/public/ or RewriteBase /projectname/ . Still no success.

Of course, I am not sure if the .htaccess is the problem. May be something different but I have no idea what...

On localhost the application is working and everything is OK there.

Edit: After several changes that I try I finally get it working.

Here is the solution:

I leaved server's .htaccess file as is. So it has only RewriteBase / on it. Then on the first line of my .htaccess file (which is in the projectname/public folder) I added this:

RewriteBase /projectname/public

Now everything is working.

Solution

Leave server's .htaccess file as is. So there is only RewriteBase / in it. Then on the first line of application's .htaccess file (which is in the projectname/public folder) add this line:

RewriteBase /projectname/public

Your domain name (your url) has to point to /projectname/public/ and you won't need to add anything in your .htaccess file. As an example, here is my own .htaccess file (generated when creating my project via Zend_Tool ). I need no RewriteBase ! :

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

SetEnv APPLICATION_ENV development

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM