laravel - 在 IIS 服务器中使用 htaccess 更改主 URL
问题描述
我正在 IIS 服务器上使用 laravel 5.6 项目。
我想使用 htaccess 更改
domain.com/
为domain.com/something
我的项目的主要 url,但我找不到任何东西。
这是我当前的 .htaccces 文件
选项 -MultiViews -Indexes
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
有什么帮助吗?
解决方案
根据 htaccess 文件内容,我已经转换了 IIS UrlRewrite 规则中的规则。要应用这些规则,请在您的网站根目录中创建 web.config 文件并粘贴以下内容。如果文件已经存在,只需复制该rewrite
部分
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rule 1" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{URL}" pattern="(.+)/$" ignoreCase="false" />
</conditions>
<action type="Redirect" url="{C:1}" redirectType="Permanent" />
</rule>
<rule name="Rule 2" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<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>
<rule name="redirect" stopProcessing="true">
<match url="^$" />
<action type="Redirect" url="/subdir" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
推荐阅读
- c# - 我的查询(包括加密数据)可以优化吗
- java - Bean Validation 和更改集合
- excel - 为什么 PasteSpecial 方法有时会抛出错误 1004?
- c# - 时间:2019-05-10 标签:c#global exception handlerWeb-API
- linux - Linux 如何从新环境运行 bash 脚本?
- node.js - 澄清 Heroku CLI + Github 工作流程?
- javascript - 两个文本字段之间的验证,vuetify
- javascript - JavaScript 基本函数验证运行时错误
- javascript - vue:拼接对当前元素不起作用
- c - (struct Node*)malloc(sizeof(struct Node)); 之间的区别 和 malloc(sizeof(struct Node));