【发布时间】:2020-12-15 14:06:22
【问题描述】:
我有一个场景,如果 URL 在 URI 段中不包含任何内容,则无需重写 index.php,但如果包含则重写它。
例如:http://www.example.com/ 或 http://www.example.com 不需要重写规则
但如果 URL 是 http://www.example.com/homepage 或 http://www.example.com/user/1 或 http://www.example.com/edit-user/123/456 那么它应该被重写为 index.php
我在下面试过了。
<rules>
<rule name="custom rule 1" stopProcessing="true">
<match url="^([^/]+)/?$" />
<action type="Rewrite" url="index.php" />
</rule>
它适用于 http://www.example.com/ 和 http://www.example.com/homepage,但其他页面显示 404。
URI 段是动态的,可以是多语言的。
使用的技术 IIS、PHP (Laravel)
【问题讨论】:
标签: regex laravel iis url-rewriting url-rewrite-module