将域名x中的页面a重定向到域名y中的页面b。

huangapple go评论59阅读模式
英文:

redirect page a in domain x to page b in domain y

问题

I know it may be duplicate in some cases but I couldn't find an exact answer for this.
I've changed my website url and I created all pages in new format, now I want to redirect old urls to new one, the urls are in persian format so this my old domain address:
old: https://sisnogroup.com/%D8%A7%D9%82%D8%A7%D9%85%D8%AA-%D8%AA%D8%AD%D8%B5%DB%8C%D9%84%DB%8C-%DA%AF%D8%B1%D8%AC%D8%B3%D8%AA%D8%A7%D9%86-%D8%A8%D8%B1%D8%A7%DB%8C-%D8%AF%D8%A7%D9%86%D8%B4-%D8%A2%D9%85%D9%88%D8%B2%D8%A7%D9%86

new: https://sisnogroup.ge/fa/%D8%A7%D9%82%D8%A7%D9%85%D8%AA-%DA%AF%D8%B1%D8%AC%D8%B3%D8%AA%D8%A7%D9%86
I want to redirect it permanently to new one.

I did some code in webconfig/iisrewrite but it returns 404.
what is the exact web.config code to do this?

<rule name="Redirect to domain 2" stopProcessing="true">
    <match url="^%D8%A7%D9%82%D8%A7%D9%85%D8%AA-%D8%AA%D8%AD%D8%B5%DB%8C%D9%84%DB%8C-%DA%AF%D8%B1%D8%AC%D8%B3%D8%AA%D8%A7%D9%86-%D8%A8%D8%B1%D8%A7%DB%8C-%D8%AF%D8%A7%D9%86%D8%B4-%D8%A2%D9%85%D9%88%D8%B2%D8%A7%D9%86$" />
    <action type="Redirect" url="https://sisnogroup.ge/fa/%D8%A7%D9%82%D8%A7%D9%85%D8%AA-%DA%AF%D8%B1%D8%AC%D8%B3%D8%AA%D8%A7%D9%86" redirectType="Permanent" />
</rule>

Update

this is the log from failed request tracing:

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
 <System>
  <Provider Name="WWW Server" Guid="{3A2A4E84-4C21-4981-AE10-3FDA0D9B0F83}"/>
  <EventID>0</EventID>
  <Version>1</Version>
  <Level>5</Level>
  <Opcode>10</Opcode>
  <Keywords>0x400</Keywords>
  <TimeCreated SystemTime="2023-06-23T08:45:41.197Z"/>
  <Correlation ActivityID="{80009014-0000-9500-B63F-84710C7967BB}"/>
  <Execution ProcessID="16364" ThreadID="13304"/>
  <Computer>WIN-KF45KMECN9L</Computer>
 </System>
 <EventData>
  <Data Name="ContextId">{80009014-0000-9500-B63F-84710C7967BB}</Data>
  <Data Name="Pattern">^%D8%A7%D9%82%D8%A7%D9%85%D8%AA-%D8%AA%D8%AD%D8%B5%DB%8C%D9%84%DB%8C-%DA%AF%D8%B1%D8%AC%D8%B3%D8%AA%D8%A7%D9%86-%D8%A8%D8%B1%D8%A7%DB%8C-%D8%AF%D8%A7%D9%86%D8%B4-%D8%A2%D9%85%D9%88%D8%B2%D8%A7%D9%86$</Data>
  <Data Name="Input">robots.txt</Data>
  <Data Name="Negate">false</Data>
  <Data Name="Matched">false</Data>
 </EventData>
 <RenderingInfo Culture="en-US">
  <Opcode>PATTERN_MATCH</Opcode>
  <Keywords>
   <Keyword>Rewrite</Keyword>
  </Keywords>
 </RenderingInfo>
 <ExtendedTracingInfo xmlns="http://schemas.microsoft.com/win/2004/08/events/trace">
  <EventGuid>{0469ABFA-1BB2-466A-B645-E3E15A02F38B}</EventGuid>
 </ExtendedTracingInfo>
</Event>
英文:

I know it may be duplicate in some cases but I couldn't find an exact answer for this.
I've changed my website url and I created all pages in new format, now I want to redirect old urls to new one, the urls are in persian format so this my old domain address:
old: https://sisnogroup.com/%D8%A7%D9%82%D8%A7%D9%85%D8%AA-%D8%AA%D8%AD%D8%B5%DB%8C%D9%84%DB%8C-%DA%AF%D8%B1%D8%AC%D8%B3%D8%AA%D8%A7%D9%86-%D8%A8%D8%B1%D8%A7%DB%8C-%D8%AF%D8%A7%D9%86%D8%B4-%D8%A2%D9%85%D9%88%D8%B2%D8%A7%D9%86

new: https://sisnogroup.ge/fa/%D8%A7%D9%82%D8%A7%D9%85%D8%AA-%DA%AF%D8%B1%D8%AC%D8%B3%D8%AA%D8%A7%D9%86
I want to redirect it permenantly to new one.

I did some code in webconfig/iisrewrite but it returns 404.
what is the exact web.config code to do this?

                &lt;rule name=&quot;Redirect to domain 2&quot; stopProcessing=&quot;true&quot;&gt;
                    &lt;match url=&quot;^%D8%A7%D9%82%D8%A7%D9%85%D8%AA-%D8%AA%D8%AD%D8%B5%DB%8C%D9%84%DB%8C-%DA%AF%D8%B1%D8%AC%D8%B3%D8%AA%D8%A7%D9%86-%D8%A8%D8%B1%D8%A7%DB%8C-%D8%AF%D8%A7%D9%86%D8%B4-%D8%A2%D9%85%D9%88%D8%B2%D8%A7%D9%86$&quot; /&gt;
                    &lt;action type=&quot;Redirect&quot; url=&quot;https://sisnogroup.ge/fa/%D8%A7%D9%82%D8%A7%D9%85%D8%AA-%DA%AF%D8%B1%D8%AC%D8%B3%D8%AA%D8%A7%D9%86&quot; redirectType=&quot;Permanent&quot; /&gt;
                &lt;/rule&gt;

Update

this is the log from failed request tracing:

    &lt;Event xmlns=&quot;http://schemas.microsoft.com/win/2004/08/events/event&quot;&gt;
 &lt;System&gt;
  &lt;Provider Name=&quot;WWW Server&quot; Guid=&quot;{3A2A4E84-4C21-4981-AE10-3FDA0D9B0F83}&quot;/&gt;
  &lt;EventID&gt;0&lt;/EventID&gt;
  &lt;Version&gt;1&lt;/Version&gt;
  &lt;Level&gt;5&lt;/Level&gt;
  &lt;Opcode&gt;10&lt;/Opcode&gt;
  &lt;Keywords&gt;0x400&lt;/Keywords&gt;
  &lt;TimeCreated SystemTime=&quot;2023-06-23T08:45:41.197Z&quot;/&gt;
  &lt;Correlation ActivityID=&quot;{80009014-0000-9500-B63F-84710C7967BB}&quot;/&gt;
  &lt;Execution ProcessID=&quot;16364&quot; ThreadID=&quot;13304&quot;/&gt;
  &lt;Computer&gt;WIN-KF45KMECN9L&lt;/Computer&gt;
 &lt;/System&gt;
 &lt;EventData&gt;
  &lt;Data Name=&quot;ContextId&quot;&gt;{80009014-0000-9500-B63F-84710C7967BB}&lt;/Data&gt;
  &lt;Data Name=&quot;Pattern&quot;&gt;^%D8%A7%D9%82%D8%A7%D9%85%D8%AA-%D8%AA%D8%AD%D8%B5%DB%8C%D9%84%DB%8C-%DA%AF%D8%B1%D8%AC%D8%B3%D8%AA%D8%A7%D9%86-%D8%A8%D8%B1%D8%A7%DB%8C-%D8%AF%D8%A7%D9%86%D8%B4-%D8%A2%D9%85%D9%88%D8%B2%D8%A7%D9%86$&lt;/Data&gt;
  &lt;Data Name=&quot;Input&quot;&gt;robots.txt&lt;/Data&gt;
  &lt;Data Name=&quot;Negate&quot;&gt;false&lt;/Data&gt;
  &lt;Data Name=&quot;Matched&quot;&gt;false&lt;/Data&gt;
 &lt;/EventData&gt;
 &lt;RenderingInfo Culture=&quot;en-US&quot;&gt;
  &lt;Opcode&gt;PATTERN_MATCH&lt;/Opcode&gt;
  &lt;Keywords&gt;
   &lt;Keyword&gt;Rewrite&lt;/Keyword&gt;
  &lt;/Keywords&gt;
 &lt;/RenderingInfo&gt;
 &lt;ExtendedTracingInfo xmlns=&quot;http://schemas.microsoft.com/win/2004/08/events/trace&quot;&gt;
  &lt;EventGuid&gt;{0469ABFA-1BB2-466A-B645-E3E15A02F38B}&lt;/EventGuid&gt;
 &lt;/ExtendedTracingInfo&gt;
&lt;/Event&gt;

答案1

得分: 0

我找到了问题,它涉及到URL中的波斯字符,在规则的模式部分,我复制并粘贴了波斯编码字符,所以它似乎与URL的确切值不同,例如,在模式部分,你应该使用类似以下的内容:

^بهترین-شرکت-خدمات-در-ایران&amp;

而不是我在问题中提到的包含百分号的内容。希望对其他遇到相同问题的人有所帮助。

英文:

I found the problem, it was about Persian characters in URLs,
in the pattern section of the rule, I copied and past the Persian encoded character so it seems it's different from the exact value of the URL,
for example, in the pattern section, you should use something like:

^بهترین-شرکت-خدمات-در-ایران&amp;

not something like that I mentioned in my question which contains % signs.
hope it helps other with the same problem.

huangapple
  • 本文由 发表于 2023年6月22日 15:02:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76529327.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定