在永久链接中获取参数变量

时间:2014-05-06 13:08:59

标签: php apache mod-rewrite rewrite permalinks

我的页面显示了数据库的最后10篇文章,并且使用$_GET['show-all']变量显示了所有文章。

现在,我想使用固定链接。对于'标准'页面,永久链接是

/articles

对于第二个,我可能会使用这个

/articles/show-all

但谷歌将搜索引擎识别为另一个页面,并生成重复的元标记错误。所以我想用这个固定链接

/articles/?show-all

但我的所有尝试都没有奏效。我在.htaccess文件中尝试了这段代码:

RewriteRule ^articles/?(.*)$ /3/contents.php?p=articles&$1 [L]

RewriteRule ^articles/\?(.*)$ /3/contents.php?p=articles&$1 [L]    

2 个答案:

答案 0 :(得分:1)

尝试始终使用尾部斜杠。

自/ name!= / name /

因此,在你的情况下去/ name?param。

这个主题有很多关于它的信息: When should I use a trailing slash in my URL?

答案 1 :(得分:1)

看一下规范标签

http://en.wikipedia.org/wiki/Canonical_link_element

避免“重复内容”;)