簡體   English   中英

重寫web.config中的URL

[英]Rewrite URL in web.config

現在,我的網站像這樣工作,每當我點擊我的根站點鏈接mysite.com時,我就會獲得mysite.com/public,並且子頁面也可以作為mysite.com/public/login進行訪問。 我想從所有URL中刪除“公共”。

這是我的web.config(使用Laravel的原始版本)

<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>

您需要設置您的Web服務器,以便/ public文件夾是站點根目錄。 如果必須為每個URL加上/ public前綴,則表示當前指向應用程序根目錄。

將.htaccess從公共目錄復制到主目錄,將server.php文件更改為主目錄中的index.php

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM