nginx redirect root / to /wordpress/

Since WordPress is installed under /wordpress/ url.

and root / URL do not have any important content. so we need redirect URL / to URL /wordpress/

hear is the Nginx code to redirect

so at nginx.conf under server block add below

location = / {
        return 301 /wordpress/;
}

location = / means when user is access URL /

301 is http redirect code. the browser will do redirect to another place.

/wordpress/ is after 301, so this is the place where browser will redirect to.

so it will redirect / to /wordpress/.

Leave a Reply