Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Azure中部署的Laravel web应用中的HTTPS路由_Php_Laravel_Azure_Https_Web Config - Fatal编程技术网

Php Azure中部署的Laravel web应用中的HTTPS路由

Php Azure中部署的Laravel web应用中的HTTPS路由,php,laravel,azure,https,web-config,Php,Laravel,Azure,Https,Web Config,我想通过HTTPS强制路由。我在Azure云平台中有一个web应用程序,在/public文件夹中有以下web.config文件: <configuration> <system.webServer> <rewrite> <rules> <rule name="Imported Rule 1" stopProcessing="true"> <match url="^(.*)

我想通过HTTPS强制路由。我在Azure云平台中有一个web应用程序,在/public文件夹中有以下web.config文件:

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Imported Rule 1" stopProcessing="true">
          <match url="^(.*)/$" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
          </conditions>
          <action type="Redirect" redirectType="Permanent" url="/{R:1}" />
        </rule>
        <rule name="Imported Rule 2" stopProcessing="true">
          <match url="^" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

要添加以下内容:

<system.webServer>
   <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}”/>
         </rule>
      </rules>
    </rewrite>
</system.webServer>

您知道如何更改原始web.config文件,使其适合并强制使用HTTPS吗

已解决

我只需要添加规则。修改后的web配置为:

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Imported Rule 1" stopProcessing="true">
          <match url="^(.*)/$" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
          </conditions>
          <action type="Redirect" redirectType="Permanent" url="/{R:1}" />
        </rule>
        <rule name="Imported Rule 2" stopProcessing="true">
          <match url="^" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php" />
          <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}”/>
         </rule>
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

我相信您可以从Laravel方面解决这个问题

考虑以下路线:

Route::get('signin', ['uses' => 'AuthController@signin', 'https']);

此路由将仅用作https。不久前我不得不处理这种情况。

我相信你可以从拉雷维尔方面解决这个问题

考虑以下路线:

Route::get('signin', ['uses' => 'AuthController@signin', 'https']);

此路由将仅用作https。不久前我不得不处理这种情况。

如果您的laravel应用程序的目录体系结构如下所示:

wwwroot/
    app/
    public/
    ...
    .env
    ...
您可以直接创建一个文件
web.config
,其中包含应用程序根目录中的内容:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
   <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}/public/{R:1}"/>
         </rule>
      </rules>
    </rewrite>
</system.webServer>
</configuration>

它将所有HTTP请求重定向到HTTPS,并重定向到公用文件夹中的


如有任何其他问题,请随时通知我。

如果您的laravel应用程序的目录体系结构如下:

wwwroot/
    app/
    public/
    ...
    .env
    ...
您可以直接创建一个文件
web.config
,其中包含应用程序根目录中的内容:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
   <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}/public/{R:1}"/>
         </rule>
      </rules>
    </rewrite>
</system.webServer>
</configuration>

它将所有HTTP请求重定向到HTTPS,并重定向到公用文件夹中的

如有任何进一步的问题,请随时通知我