Iis 301 ошибка

If it’s asp 2 and above you can implement it in 2 ways:
1) ASP.NET: Redirecting with ASP.NET and IIS
you can implement 301 redirects using ISAPI Rewriting modules, products like UrlRewriter.NET which is discussed in Chapter 3, «Provocative SE-Friendly URLs,» of the book, Professional Search Engine Optimization with ASP.NET: A Developer’s Guide to SEO, or from within your ASP.NET code by setting the appropriate header data.

When using ISAPI_Rewrite, redirecting is implemented similarly to URL rewriting, except that you specify a redirection status code as a parameter.

Example :
The following rule does a 301 redirect to Catalog.aspx when the initial request is for Catalog.html:

301 Redirect Catalog.html to
Catalog.aspx RewriteRule
^/Catalog.html$
http://seoasp/Catalog.aspx [RP]

2) In Code
If you want to implement the redirect yourself, you need to manipulate the response headers using the Response object provided by your current HttpContext object. Here’s how to 301 redirect Catalog.html to Catalog.aspx yourself:
if (context.Request.Path == «/Catalog.html»)
{
context.Response.Status = «301 Moved Permanently»;
context.Response.AddHeader(«Location», «http://www.example.com/Catalog.aspx»);
}
Explanation: The first URL should be a relative path to the old URL and the second one should be an absolute path to the new URL.

  • Remove From My Forums
  • Question

  • User812077396 posted

    I have created a website www.domain.com with the same host name on a Windows Server 2017 cloud server in IIS 10 and bound to SSL as HTTPS://

    The issue I am having is that everytime I enter
    https://www.domain.com in my browser, a 301 error redirects to the non www
    https://domain.com which does not exist on the server.

    There are no rules in URL rewrite/web.config file to drive this behaviour. In fact if I create a non-www to www redirect it just loops because of the above.

    I have tried everything I can think of, including deleting and recreating the site but something in the background seems to be driving this.

    Any suggestions appreciated

Our Picks

Demo

Order Now

A site can help private endeavors increase versatility, control, checking, and justice. 84% of buyers…

Still, there are a lot of essential ways to deal with improve your WordPress site’s…

How to Write a Blog Post For Ranks on Google? you have the chance to go deeply into your favorite subjects, showcase…

Read More

If you’re looking for a hosting company, you’ll quickly learn that there are Types of Hosting Services options with various costs, features,…

Read More

For businesses to succeed and successfully reach their target audience in the modern digital era, Key Elements of Your Online Strategy is…

Read More

An Effective Marketing Plan supports a company’s growth and frequently even its continuation. The right strategy increases your chances of succeeding in…

Read More

Most likely, you want more people to visit your website. After all, more business income must equate to increased traffic. Absolutely not.…

Read More

New Workouts

Subscribe to Updates

Get the latest creative news from FooBar about art, design and business.

Попросил знакомый помочь ему настроить пересылку (301 redirect) со старых страниц сайта на новые, так как он поменял структуру сайта, доставшийся ему в наследство вместе с Windows сервером, понятно, что на IIS.

Решение:

Убеждаемся, что роль перенаправления HTTP включена.

Диспечер сервера Win

Если не установлено, добавляем службу ролей.

Запускаем Диспетчер служб IIS, переходим на вкладкуПросмотр содержимого и выбираем требуемый файл или каталог.

Диспечер служб IIS7

Нажимаем правой кнопкой мыши, Переключится в режим просмотра возможностей, затем выбираем Перенаправление протокола HTTP

Перенаправление протокола HTTP IIS

И заполняем требуемые поля, затем нажимаем Применить.

Так же можно решить другим способом, в каталоге где находится объект с которого требуется сделать редирект, редактируем файл web.config и приводим к виду:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 <location path="1.html">
 <system.webServer>
 <httpRedirect enabled="true" destination="http://i-rrv.ru/2.html" exactDestination="true" httpResponseStatus="Permanent" />
 </system.webServer>
 </location>
 <location path="3.html">
 <system.webServer>
 <httpRedirect enabled="true" destination="http://i-rrv.ru/4.html" exactDestination="true" httpResponseStatus="Permanent" />
 </system.webServer>
 </location>
</configuration>

В этом примере настроен редирект 301 двух файлов 1.htmlна http://i-rrv.ru/2.html и 3.html на http://i-rrv.ru/4.html

Join @AdmNtsRu on Telegram

Смотрите также:

Понравилась статья? Поделить с друзьями:
  • Ig5a частотный преобразователь коды ошибок
  • Iiko delivery man ошибка
  • Ii e1003 ошибка эпик геймс
  • Igo ошибка инициализации карты
  • Ig5a ошибка oct