I have a Wordpress instance running fine, and i have a directory on my server that needs to redirect users to another domain outside the main server using a 302 rule. I add this on my server block and the redirection works fine:
server {
listen 80;
server_name domain.com;
location /lps {
return 302 https://newdomain/$request_uri;
}
}
but when i go to domain.com i got a 404 Not Found error.
I also try without luck.
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
CodePudding user response:
I manage to solve my issue with this:
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Main Server Config
server {
listen 80;
server_name localhost;
root /home/site/wwwroot;
index index.html index.htm index.php;
error_page 500 502 503 504 /50x.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location /lps {
return 302 https://newdomain.net/$request_uri;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
My Azure container have FastCGI and had to add the php instruction