如何从teamquadb.php?URL = vms重写规则到/ teamquadb / vms

时间:2019-03-31 12:37:12

标签: php .htaccess

我来自RewriteRule的{​​{1}}无效:

teamquadb.php?url= to teamquadb\___

1 个答案:

答案 0 :(得分:1)

您的斜杠使用了错误的方式,您的模式期望URL末尾再加上一个斜杠。

尝试:

RewriteEngine on
RewriteRule ^teamquadb/([^/]+)/?$ teamquadb.php?url=$1 [nc]

通过https://htaccess.madewithlove.be/

测试您的规则

更新

扩展此答案,以回应OP对它的评论。

要获取 teamquadb / vms / 1 路由到 teamquadb.php?url = vms&numberq = 1

RewriteEngine on
RewriteRule ^teamquadb/([^/]+)/?$ teamquadb.php?url=$1 [nc]
RewriteRule ^teamquadb/vms/([^/]+)/?$ teamquadb.php?url=vms&numberq=$1 [nc]

测试:https://htaccess.madewithlove.be?share=2e96e804-9415-54bf-84d0-062d9b501f68

要获取 teamquadb / [SOMETHING#1] / [SOMETHING#2] 以路由到 teamquadb.php?url = [SOMETHING#1] &numberq = [SOMETHING#2] ,我们将使用

RewriteEngine on
RewriteRule ^teamquadb/([^/]+)/?$ teamquadb.php?url=$1 [nc]
RewriteRule ^teamquadb/([^/]+)/([^/]+)/?$ teamquadb.php?url=$1&numberq=$2 [nc]

测试:https://htaccess.madewithlove.be?share=2e96e804-9415-54bf-84d0-062d9b501f68