RewriteRule - 删除参数键并将值保留在地址栏中

RewriteRule - remove params keys and keep values in address bar

RewriteEngine ON    
RewriteRule ^video$ video.php [L] 

以上行有效
example.com/video 被解释为 example.com/video.php

现在我需要example.com/video?id=5&s=lorem-ipsum
解释为 example.com/video/5/lorem-ipsum - 反之亦然

RewriteCond %{THE_REQUEST} video?id=([^\s&]+)&s=([^\s&]+) [NC]
RewriteRule ^ %1/%2? [R=301,L]
RewriteRule ^([\w-]+)/([\w-]+)/?$ video?id=&s= [L,QSA]
RewriteRule ^([\w-]+)/([\w-]+)/?$ video?// [L,QSA]  

两个方向都行不通
请帮忙

根据您显示的尝试,请尝试遵循 .htaccess 规则文件。这些规则假设你想重写 index.php 你可以根据你的要求在第二组规则中更改 php 文件名。

确保在测试您的 URL 之前清除您的浏览器缓存。

RewriteEngine ON
##External redirect Rules from here..
##Redirect 301 to example.com/video/5/lorem-ipsum from example.com/video?id=5&s=lorem-ipsum
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{THE_REQUEST} \s/(video)\?id=([^&]*)&s=(\S+)\s [NC]
RewriteRule ^ /%1/%2/%3? [R=301,L]

##Internal rewrite for example.com/video?id=5&s=lorem-ipsum
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^video/([^/]*)/(.*)/?$ index.php?id=&s= [QSA,NC,L]