How to change the structure of my URLs along with the Sitemap for a live website?

by Hooman Bahreini   Last Updated August 03, 2019 12:04 PM

I am changing my website's URL to improve the SEO. The current sitemap contains URLs like this:

mysite/browse/1    /* 1 is the ID for fashion */
mysite/browse/2    /* 2 is the ID for real estate */

Now I have changed the URLs to the following format:


I have have the code ready to be released along with the new sitemap. If I release the new code, the old URLs would no longer be valid, ie: mysite/browse/2 would return "404 - page not found".

I believe I have to release the code and submit the new sitemap to Google Search Console. But I believe it would take Google sometime before actually crawling the new sitemap, so during this time, all my old urls which appear in the search result would return "404 - page not found" error.

How can I mitigate this situation?

Tags : seo url sitemap

Answers 1

You must redirect 301 each old url to its new value. For example If using IIS 7 or higher, the simplest solution is to use the httpRedirect element in your web.config.

<httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Permanent">
     <add wildcard="/browse/1" destination="/browse/fashion" />
     <add wildcard="/browse/2" destination="/browse/real-estate" />

Adapted the source from this Answer: but I'm not familiar with IIS and you may have to look further to adapt to your case.

And on Apache server in your .htaccess file:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^browse/1$  /browse/fashion [R=301,L]
    RewriteRule ^browse/2$  /browse/real-estate[R=301,L]

So that old pages wont lead to 404 and Google will quickly replace URLs in SERP.

And of course you will be able to release your code and new sitemap without error nor seo loss.

August 03, 2019 10:13 AM

Related Questions

Updated November 29, 2018 18:04 PM

Updated August 28, 2019 17:04 PM

Updated April 07, 2016 08:01 AM

Updated July 06, 2016 09:01 AM

Updated January 12, 2018 08:04 AM