Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache htaccess删除获取参数键而不是值_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Apache htaccess删除获取参数键而不是值

Apache htaccess删除获取参数键而不是值,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我正在尝试从我的url中删除get密钥 所以test?category=indent&index=0将变成test/indent/0 我一整天都在努力,但毫无结果。我发现学习apache非常困难。任何朝着正确方向的点都将不胜感激。这条规则应该适用于您: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^test/([^/]+)/([^/]+)

我正在尝试从我的url中删除get密钥

所以
test?category=indent&index=0
将变成
test/indent/0


我一整天都在努力,但毫无结果。我发现学习apache非常困难。任何朝着正确方向的点都将不胜感激。

这条规则应该适用于您:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^test/([^/]+)/([^/]+)/?$ test?category=$1&index=$2 [L,QSA,NC]

参考:将这些规则添加到文档根目录中的htaccess文件中

RewriteEngine On

# to externally redirect
RewriteCond %{THE_REQUEST} \ /test\?category=([^&]+)&index=([0-9]+)
RewriteRule ^test$ /test/%1/%2 [L,R=301]

# to internally rewrite back
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^test/([^/]+)/([0-9]+)$ /test?category=$1&index=$2 [L]

也感谢外部支持:)