.htaccess 在htaccess重写规则的URL中包含斜杠

.htaccess 在htaccess重写规则的URL中包含斜杠,.htaccess,.htaccess,我的htaccess文件中有以下重写规则: RewriteRule ^([^/]+)/?$ index.php?id=$1 [QSA] 在index.php上,我有echo$_GET[“id”] 它工作正常,因此domain.com/services重写为domain.com/index.php?id=services domain.com/services/service1 回显变量显示为404.shtml 我需要什么规则来允许斜杠?非常简单。您已将规则设置为匹配除斜杠以外的任何。什么都可

我的htaccess文件中有以下重写规则:

RewriteRule ^([^/]+)/?$ index.php?id=$1 [QSA]
在index.php上,我有
echo$_GET[“id”]

它工作正常,因此
domain.com/services
重写为
domain.com/index.php?id=services

domain.com/services/service1
回显变量显示为
404.shtml


我需要什么规则来允许斜杠?

非常简单。您已将规则设置为匹配除斜杠以外的任何。什么都可以

RewriteRule ^(.+)/?$ index.php?id=$1 [QSA]

你会期待什么?id是空的或者它有service1?也许我应该更具体一点!检查我的更新ID应为ID=services/service1是否希望ID为services/service1?您应该在问题中输入您期望的id的确切字符串。