मैं 301
स्थिति कोड लौटाते समय सभी http ट्रैफ़िक को https पर पुनर्निर्देशित करने का प्रयास कर रहा हूं। तो मेरे पास यह मेरी Web.Release.config फ़ाइल में है।
<rewrite>
<rules>
<rule name="Redirect to https" xdt:Transform="Insert">
<match url="(.*)"/>
<conditions>
<add input="{HTTPS}" pattern="Off"/>
<add input="{REQUEST_METHOD}" pattern="^get$|^head$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" statusCode="301" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
और मुझे 301
के बजाय 307
मिलता रहता है। मैं इसे 301
स्थिति कोड वापस करने के लिए कैसे बाध्य कर सकता हूं?
1 उत्तर
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" statusCode="301" redirectType="Permanent" />
आपके कोड के अनुसार, हम पा सकते हैं कि आप redirectType="Permanent"
निर्दिष्ट करते हैं, इसे 301 स्थिति कोड वापस करना चाहिए। मैं अपनी तरफ से इस मुद्दे को पुन: पेश करने का प्रयास करता हूं, यहां मेरी कॉन्फ़िगरेशन फ़ाइलें हैं।
वेब.कॉन्फ़िगरेशन
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=169433-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5"/> <httpRuntime targetFramework="4.5"/>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
</compilers>
</system.codedom>
</configuration>
वेब.रिलीज.कॉन्फिग
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--In the example below, the "SetAttributes" transform will change the value of "connectionString" to use "ReleaseSQLServer" only when the "Match" locator finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB" connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>-->
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<!--In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm" mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>-->
</system.web>
<system.webServer xdt:Transform="Insert">
<rewrite>
<rules>
<rule name="Redirect to https">
<match url="(.*)"/>
<conditions>
<add input="{HTTPS}" pattern="Off"/>
<add input="{REQUEST_METHOD}" pattern="^get$|^head$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
जब मैं अपनी वेबसाइट पर जाता हूं तो मुझे नेटवर्क टूल में 301 स्थिति कोड दिखाई देता है।
मैं 301 के बजाय 307 प्राप्त करता रहता हूं। मैं इसे 301 स्थिति कोड वापस करने के लिए कैसे बाध्य कर सकता हूं?
आप अपनी Web.config फ़ाइल की जांच कर सकते हैं और सुनिश्चित कर सकते हैं कि क्या आप अन्य URL पुनर्लेखन नियमों को परिभाषित करते हैं जो स्थिति कोड बदलते हैं।
संबंधित सवाल
नए सवाल
redirect
एक वेबसर्वर द्वारा प्रतिक्रिया, जो उपयोगकर्ता एजेंट को प्रतिक्रिया निकाय नहीं दिखाने के लिए कहता है, लेकिन इसके बजाय एक अलग संसाधन का अनुरोध करता है। प्रश्न रीडायरेक्ट प्रोटोकॉल, लिंक इक्विटी और रीडायरेक्ट के प्रकार से संबंधित हो सकते हैं।