Convert 404/500 or any other error code to 301 - asp.net-mvc

I have site in Mvc and i want that any URL with error code 404 will redirect to 301.
Where i can do this permanently(Web.Config/IIS) and how?
Please suggest me the option keeping in mind the SEO part of a site.
I have hundreds of Urls generating 404 and 500 errors i want to redirect them to site base url "www.site.com"
I have error links like this:
www.site.com/index.php?page=item&id=39
www.site.com/Ad/Detail/b7bd026f-3ba2-444f-8786-6e551d6e1668

Related

Googlebot 404 crawl errors after website changed

I had an old asp.net website (aspx) and have redesigned it with asp.net MVC using SSL. Anyway, after I promoted the new site I saw a ton of errors which were being generated by bots looking for old pages; the errors were looking something like this: The controller for path '/blablabla/moreBlalbalba/page.aspx' was not found or does not implement IController. So, I updated my error handling to return a 301 response and redirect to the home page and added a sitemap. The google 404 console errors went away for around a month, but now have a ton of 404 errors and they are all pointing to the old site structure. As a side note, the new MVC/SSL site has no 404 errors in the webmaster console, all the errors are on the non SSL site. So, what is the best way to update the bots for the new site structure.
Thanks!
I would suggest you to redirect all traffic from HTTP to HTTPS, using this example. This may solve your problem already.
And secondly create a sitemap for Google to check the relevant pages of the website, example here

Google is indexing post actions

I have developed an ASP.NET MVC 5 website that uses jQuery and ajax requests to pull and post data. Google's crawlers found my POST action urls in Javascript code and tried to index them.
In Webmaster Tools I see a lot of errors like that /Account/Login with a 500 error response because obviously a name and a password were not provided. How can I solve this problem? I don't want any crawl error, but I don't know how to say to Google not to follow these urls.
Thank you!
Use Google's instructions to create a robots.txt file, which is a request to a search engine to not index.
A sample robots.txt to put in the root of your domain may look like this:
User-agent: Googlebot
Disallow: /path/to/my/post/url

How to handle requests to clearly but wrong defined resource?

Given I use an CMS which makes an article available unter the following URL: http://example.com/article/1-my-first-and-famous-article/
Internally I can identify the requested article unequivocally by its id (1).
How should I handle requests to a wrong (typing error, manipulation, ..) URL? For example someone requests http://example.com/article/1-my-firsz-and-famous-article/ or http://example.com/article/1-this-article-is-stupid-idiot/ - should I respond with http status code 301 and redirect to the right URL or with 404 and show a not found page (maybe with redirection after a few seconds). Which is the preferable way in terms of search engine optimization?
Wrong URLs will be 404 error and any existing page moved to new location will be 301 redirect

Can I mask a display URL?

I have the URL of my website: www.domain.com and I have setup a wordpress blog on blog.domain.com.
Is there a way I can mask the Wordpress URL to always look like www.domain.com? (i.e. although it is accessing blog.domain.com, can I rewrite the URL to read www.domain.com)
Can I force a 404 at www.domain.com to redirect to blog.domain.com and then if not found show 404 page? (i.e. Check www.domain.com first, if not found then check blog.domain.com and then if not foun, throw the 404 page in the blog)
Thanks in advance

Redirect on record not found?

On the book Agile Web development with Rails, it is proposed that when someone tries to access some data in your web site and the record doesn't exist anymore, that the user should be redirected to a working page and display a message.
A user would go to /book/1, but a book with id 1 doesn't exist anymore, so it is redirected to /books and shown a message "That book doesn't exist". It seems to be a good user experience but to break the HTTP protocol. Should it be a temporary redirect? if so a web crawler will keep hitting that page. Should it be a permanent redirection? If so the previous content should be available there, and it isn't.
I think that a record-not-found page should issue a 404. Am I wrong? Hitting /book/1 where 1 doesn't exist anymore would return a 404 with the HTML showing exactly the same thing as /books, and maybe an error message.
Agile Web development with Rails is against that option because the user might keep hitting /book/1 generating 404s only to see what can be seen in /books.
What do you think?
If the resource does not exist, send the 404 status code. It’s really that simple. Redirecting means that only the URL is (temporarily) not valid but the resource does exist.
If there's no 404 , search engines have no way to discover that the object has been deleted. So I suppose it's a must.
I think there's a good compromise where you render a 404 template (complete with 404 status code) that prompts the user to continue to /books or /whatever.
if the record doesn't exist anymore, than you should probably use a 301 status code, "permanent redirect".
The difference between 301 and 404, is that a 404 error code should be used in cases when the resource never existed and 301 when the resource existed, but moved.

Resources