开发者

Redirect website on asp.net

I've a website composed by some .asp file and a lot of static .html

I want to redirect all

www.e开发者_运维百科xample.old/abc.html

www.example.old/xyz.html

to

www.example.new/abc.html

www.exaple.new/xyz.html

If I'm on Apache I would use a .htaccess but how could I do that on a ASP, ASP.NET server? (I don't have access to IIS manager)

.NET Fw: 3.5 OS: Windows 2003 IIS: 6.0


Try this in your web.config file:

<rule name="Redirect Rule" stopProcessing="true"> 
<match url=".*/(.*)" />
<action type="Redirect" url="www.example.new/{R:1}" redirectType="Permanent" /> 
</rule>


You can do this with global.asax

If this is a permanent redirect then you will want to use a 301 redirect rather than a 302 to allow search engine crawlers to update their links.

Response.Clear();
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.example.new/abc.html");
Response.End();

Edit: You can't do this if the pages are html and not handled by the ASP.NET ISAPI filter, you can configure this through IIS manager but you stated that you don't have access.

For ASP you could use the predecessor to global.asax - global.asa

For the HTML you are probably stuck with a meta refresh.


If you're using classic ASP...In your global.asa file...you can add code that redirects all requests for .asp files to your new site.

If you're using ASP.NET, you can add code in your global.asax file, Session_Start method that redirects the user.

For your html pages, since they aren't run by the ASP and ASP.NET engine, you'll have to replace them all with a blank html page that only has a meta refresh tag to the new domain & page.

If you have access to the IIS, you can change the 404.htm file that it uses. Add a meta refresh tag to it so all other requests are sent to your site as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜