How do i redirect my website from nonwww to www?

shotvpro

New member
Joined
Dec 9, 2024
Messages
1
Points
0
Hi, I have my website. I recently indexed my website on google, but the same page is getting indexed in 2 URL's.
One with www and other without www. How do I redirect my non-www page to www? please help me.
The site is working on next.js platform.
 

topafricans

New member
Joined
Dec 17, 2024
Messages
1
Points
0
use this code on your server

server { listen 80; server_name yourdomain.com; return 301 http://www.yourdomain.com$request_uri; }
server { listen 80; server_name www.yourdomain.com; root /path/to/your/site; # Other server configurations }
 

ashleydent4u

New member
Joined
Nov 21, 2024
Messages
5
Points
1
Hey! To fix the issue of your site being indexed with both www and non-www URLs, you need to set up a redirect. Since you're using Next.js, you can do this by adding a rewrite rule in your next.config.js file.
 
Newer threads
Latest threads
Replies
0
Views
54
Replies
4
Views
285
Replies
3
Views
242
Replies
0
Views
195
Replies
0
Views
168
Top