我的网站网址是这样的。
https://example.com/page/1/?orderby=low_to_high&s=demo+post&post_type=post&twdg_wsac=1
我想使用htaccess替换此网址的某些部分,因此最终输出应如下所示
https://example.com/page/1/?orderby=low_to_high&s=demo+post&post_type=post&custom_posts=1
所以我在htaccess文件中做了这样的更改
RewriteEngine on
RewriteRule ^&twdg_wsac$ &custom_posts
但是它不起作用。您也可以在网址中看到twdg_wsac=1
。因此,最后一个“ 1”是帖子的分页,因此会根据帖子数动态变化。
那么有人可以告诉我该怎么做吗? 任何帮助和建议将非常有帮助。谢谢
更新
网址中的所有参数都是动态生成的,我的意思是这些是过滤器参数。因此除了twdg_wsac
答案 0 :(得分:0)
请尝试以下内容,我们正在对查询字符串进行重写。
RewriteEngine On
RewriteCond %{QUERY_STRING} ^orderby=(.+)&s=(.+)&post_type=(.+)&twdg_wsac=([\d]+)$
RewriteRule ^ %{REQUEST_URI}?orderby=%1&s=%2&post_type=%3&custom_posts=%4
答案 1 :(得分:0)
RewriteEngine开启 RewriteCond%{QUERY_STRING} twdg_wsac =([[d] +)$ RewriteRule ^%{REQUEST_URI}?orderby = low_to_high&s = demo + post&post_type = post&custom_posts =%1 [L]