Redirecting domain URLs with Nginx involves setting up a server block to handle the redirection. Below are steps to configure basic domain redirection:
Consider you want to redirect Old URL to New URL
Old URL
http://yourdomain.com/old-category/my-page-name
New URL
http://yourdomain.com/new-category/my-page-name
Open the Nginx configuration file: The main configuration file is usually located at /etc/nginx/nginx.conf
. However, it’s better to create or edit server-specific configuration files in the /etc/nginx/sites-available/
directory and create a symbolic link in the /etc/nginx/sites-enabled/
directory.
Inside Location: Add below configuration.
location / {
if ( $request_filename ~ old-category/my-page-name/ ) {
rewrite ^ http://yourdomain.com/new-category/my-page-name? permanent;
}
Still facing Issues ?
Contact me for paid support​ Mail me @ tutorialslides.com@gmail.com
Paid Support