[英]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.