更新时间:2023-02-23 09:25:09
简单的 .htaccess 示例:
Simple .htaccess example:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^lookup/([a-z0-9\-]+)/item/?$ /lookup.php?id=$1
</IfModule>
这将匹配任何长度的任何字母数字(也将识别破折号)字符串作为id".您可以通过将正则表达式更改为 ([0-9]+)
来将其限制为仅数字.
This will match any alphanumeric (also will recognise dashes) string of any length as the 'id'. You can limit this to just numeric by changing the regex to ([0-9]+)
.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^lookup/([a-z0-9\-]+)/([a-z0-9\-]+)/?$ /lookup.php?id=$1&view=$2
</IfModule>
这将匹配 /lookup/123/some-text/
到 /lookup.php?id=123&view=some-text