enablePrettyUrl gives 404 errors

Hi

I have moved my simple application built on top of basic template to production server. Problem is my URLs do not work anymore. If I turn off enablePrettyUrl everything works fine but URL is messy. When I turn it on I get error:


404 Not Found

nginx

I have .htaccess in my web root directory and mod_rewrite and overrides are enabled on server.


RewriteEngine on


# If a directory or a file exists, use the request directly

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

# Otherwise forward the request to index.php

RewriteRule . index.php

Any ideas what may be wrong ?

Your error indicates that production server is nginx and not apache like your dev server.

Follow instructions on http://www.yiiframework.com/doc-2.0/guide-start-installation.html#recommended-nginx-configuration to set it up.

Thanks for your reply. But I do not understand how to do Nginx configuration. Can I make some file like .htaccess with the config described like in the guide, or this has to be done on server by hosting provider ?

I’m not familiar with nginx servers but afaik you cannot configure host without reloading the whole server so if you haven’t got the access to server configuration (like on shared hosting) it is not that easy.

I hope that nginx forum users can shed some light on this.

Do anyone have any idea ?

I have only one idea because to don’t now nginx

Pretty URLs with nginx

or

forum.nginx.org

Any idea why you can’t search for it? :)

http://www.yiiframework.com/doc/guide/1.1/en/quickstart.apache-nginx-config#nginx

That is yii1. Plus it is still not clear to people that do not know how to do server configs ( like me ), do we achieve this by making some file in our app with that config or we need to bother server admins to do it.

Ngnix works that way.

If you can’t configure it, you can’t get pretty URLs.