Avatar of mmalik15
mmalik15
 asked on

redirecting the missing pages in asp.net

there are roughly 50-60 old pages which are deleted from my website www.lifeintheuktest.co and are in google index e.g. the following page http://www.lifeintheuktest.co/lifeintheuktest/archive.aspx

These pages when clicked through the search results return 404 error. I want to redirect from these pages to defualt.aspx and also want to remove them from google index. how can I redirect the missing pages to default.aspx
Microsoft IIS Web ServerC#ASP.NET

Avatar of undefined
Last Comment
JAruchamy

8/22/2022 - Mon
Paul-B

You could just set a custom 404 page for the site that has a meta refresh tag in it ...

In your new 404 page just put a line like...

<meta http-equiv="refresh" content="0;url=http://www.lifeintheuktest.co/default.aspx"> 

Open in new window

JAruchamy

Hi,

Try this in web.config

<configuration>
    <system.web>
         <customErrors defaultRedirect="error.aspx" mode="On" />
    </system.web>
</configuration>

http://www.codeproject.com/Articles/2345/Custom-Errors-in-ASP-NET
mmalik15

ASKER
Please see my web.config but for some reason its still not redirecting as you can see from the pages e.g.

http://www.lifeintheuktest.co/lifeintheuktest/?tag=/ESOL
http://www.lifeintheuktest.co/lifeintheuktest/2011/12/default.aspx

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

	<system.webServer>
		<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
			<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
			<dynamicTypes>
				<add mimeType="text/*" enabled="true" />
				<add mimeType="message/*" enabled="true" />
				<add mimeType="application/javascript" enabled="true" />
				<add mimeType="*/*" enabled="false" />
			</dynamicTypes>
			<staticTypes>
				<add mimeType="text/*" enabled="true" />
				<add mimeType="message/*" enabled="true" />
				<add mimeType="application/javascript" enabled="true" />
				<add mimeType="*/*" enabled="false" />
			</staticTypes>
		</httpCompression>
		<urlCompression doStaticCompression="true" doDynamicCompression="true" />
        <httpRedirect enabled="false" destination="" exactDestination="false" childOnly="false" httpResponseStatus="Found" />
		
	</system.webServer>

	<connectionStrings>

		*******
		

	</connectionStrings>


	

	<location path="Quiz">

		<system.web>
			<customErrors defaultRedirect="~/Error.aspx" mode="On" />
		</system.web>

		<system.web>

			<authorization>

				<allow users="user" />
				<deny users="*" />

			</authorization>

		</system.web>

	</location>

	<system.webServer>

		<defaultDocument>
			<files>
				<clear />
				<add value="default.aspx" />
			</files>
		</defaultDocument>
	</system.webServer>



	<system.web>
		<authentication mode="Forms">
			<forms path="/" loginUrl="~/Login.aspx" protection="All" timeout="5" />
		</authentication>


		<sessionState mode="InProc" cookieless="false" timeout="30" />

		<compilation debug="true" targetFramework="4.0">
			<assemblies>
				<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
				<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
				<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
				<add assembly="System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
			</assemblies>
		</compilation>
		<pages maintainScrollPositionOnPostBack="True" enableEventValidation="true" />
		<httpHandlers>
			<add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" />
		</httpHandlers>

	</system.web>


	<system.webServer>
		<validation validateIntegratedModeConfiguration="false" />
		<handlers>
			<add name="Telerik_Web_UI_WebResource_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" />
		</handlers>
	</system.webServer>
</configuration>

Open in new window

Your help has saved me hundreds of hours of internet surfing.
fblack61
mmalik15

ASKER
And I do have error page in my applications root directory. Please see the attached screenshot
Error-page.jpg
ASKER CERTIFIED SOLUTION
JAruchamy

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.