Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 .htaccess 生成漂亮的链接,我需要包含or在斜杠上
or
这样例如 domain.com/page/12/a/ 并且 domain.com/page/12/a将起作用
domain.com/page/12/a/
domain.com/page/12/a
我试过的:
RewriteRule ^page/([^/]*)/([^/]*)(/?)([^/]*) index.php?do=atoz&category=$1&letter=$2&type=$3 [L]
?在您的情况下,零或一的简单量词应该可以工作。
?
^page/([^/]*)/([^/]*)(?:/([^/]*))? ## #
编辑:您还可以寻找一个不匹配的组,以便您可以将其量化为可选。它以?:.
?: