【问题标题】:I need to rewrite a particular URL using .htaccess我需要使用 .htaccess 重写特定的 URL
【发布时间】:2013-05-04 12:50:41
【问题描述】:

我需要重写下面这个特定的 url 如下

http://myexample.com/forum/addtopics.php?id=22&type=add

http://myexample.com/forum/category_name/add

我使用了重写

重写规则 ^(.)/(.)$ forum_add.php?id=$1&type=$2

这对我不起作用...... 请帮我解决这个问题....请...

【问题讨论】:

标签: url-rewriting rewrite


【解决方案1】:

假设您已经有一个名为 addtopics.php 的文件

RewriteEngine On
RewriteRule ^forum/id/(.*)/type/(.*) addtopics.php?id=$1&type=$2

上面将形成您的网址

http://myexample.com/forum/id/22/type/add

然后就可以通过idtype查询字符串参数了

echo $_GET['id']; //will print 22
echo $_GET['type']; //will print add

【讨论】:

  • 非常感谢您的回答
  • 如果它适合你的问题,那么你应该接受这个作为答案,这样这个问题就可以被标记为完成。
猜你喜欢
  • 2023-03-20
  • 1970-01-01
  • 1970-01-01
  • 2013-03-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-14
  • 2018-06-15
相关资源
最近更新 更多