Click here to Skip to main content
15,889,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I had published my site before but to enhance SEO, recently I changed some page's names to match with keywords.

I changed the page name like this:
news page.aspx---->news-page.aspx

now I have a lot of problems with SEO. pages with previous names(news page.aspx) have indexed on google and when are clicked, the error 404returns.
"The resource cannot be found."

What I have tried:

I searched google and found that I should use redirect 301.
so I redirected the previous address to new in global.asax:

void Application_BeginRequest(object sender, EventArgs e)
    {
     if(HttpContext.Current.Request.Url.ToString().ToLower(). Contains("http://www.mysitename/news page.aspx"))
    {
        HttpContext.Current.Response.Status = "301 Moved Permanently";
        HttpContext.Current.Response.AddHeader("Location", 
        Request.Url.ToString().ToLower().
Replace("http://www.mysitename/news page.aspx","http://www.mysitename/news-page"));
    }
    }


but the page doesn't redirect and still has a "the resource not found" error.
Posted
Updated 12-Sep-21 4:30am

1 solution

Create a page with the old name, that does an immediate redirect to the new page.

Or better, handle the "not found" error and make a redirect list. If the requested page is on the list, redirect to the new location. If it isn't, log it so you can tell what they are looking for, and redirect to a custom "Sorry, but I can't find that" page.
 
Share this answer
 
Comments
mit62 12-Sep-21 10:53am    
thank you for your answer. there are a lot of pages so creating one with an old name I think is not Efficient. now how and where I should create a redirect list. also what's wrong with the code in Application_BeginRequest I wrote?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900