【发布时间】:2017-06-24 03:37:09
【问题描述】:
我有以下 .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ user.php?username=$1 [QSA]
RewriteRule ^tag/(.*)$ tag.php?tag=$1
</IfModule>
我需要涵盖以下用例:
- http://example.com/foo -> http://example.com/user.php?username=foo
- http://example.com/about -> http://example.com/about/index.php
- http://example.com/标签/栏 -> http://example.com/tag.php?tag=栏
当前的 mod_rewrite 规则涵盖情况 1 和 2(about/index.php 是真实位置)。我很难让他们覆盖案例 3。
【问题讨论】:
标签: apache .htaccess mod-rewrite