htaccess重写以删除查询参数 [英] htaccess rewriting to remove query parameters

查看:49
本文介绍了htaccess重写以删除查询参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试通过上一个关于SO的问题来找到解决方案,但是在使用它们时出现错误. 如何在URL中将该URL制成/viewpost.php?postid=81作为/viewpost/81,以便在输入/viewpost/81时显示/viewpost.php?postid=81的内容?

i have been trying to find the solution through previous question on SO, but im getting errors when using them. how to make this url : /viewpost.php?postid=81 as /viewpost/81 in the url so that when /viewpost/81 is entered, it shows the content of /viewpost.php?postid=81?

推荐答案

您必须捕获该数字并将该数字附加为查询字符串的一部分

You must capture the number and append this number as part of the query string

RewriteRule ^viewpost/(\d+)$ /viewpost.php?postid=$1 [L]

这篇关于htaccess重写以删除查询参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆