My Yii 1.1 app redirects to site.com/login
and gets error 404. Yii app hasn't any problems, it's an old app which I want to install on my server. The problem has to be with nginx configuration with mod_rewrite
because pretty urls are not processed as they should.
Here i my default.conf:
server {
include snippets/phpmyadmin.conf;
listen 80 default_server;
charset UTF-8;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /home/fornex/tmp_7offers/public/;
# Add index.php to the list if you are using PHP
index index.html index.htm index.php;
server_name localhost;
client_max_body_size 30m;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_read_timeout 60;
fastcgi_send_timeout 60;
location /public {
root /home/fornex/tmp_7offers/public/;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
error_log /var/log/nginx/error-01.log;
index index.php index.html index.htm;
# proxy_pass http://localhost:8080;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection 'upgrade';
# proxy_set_header Host $host;
# proxy_cache_bypass $http_upgrade;
if (!-e $request_filename){
rewrite ^/(.*) /index.php?r=$1 last;
}
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include snippets/fastcgi-php.conf;
include fastcgi_params;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
if ($request_uri ~ ^/(login)) {
error_page 404 =301 @redirect;
}
# With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
How can I enable mod_rewrite
so pretty urls will processed as they should?