没有任何人有任何想法,如果有可能把其他变量到您使用mod_rewrite基本上砍成变量的URL。如何添加额外的URL变量,一个URL的mod_rewrite已经改写
举例来说,如果我有网址:
website.com/post/53/post-title/
,我使用mod_rewrite把它变成:
website.com/post.php?postid=53
是存在的,优雅的方式把额外变量进入“预-rewritten“URL并将其保存为我的post.php
脚本?
IE,如果我创造什么类似下面的链接:
website.com/post/53/post-title/?anothervar=6
到目前为止,好像我的mod_rewrite代码仅仅抛出了额外的变量和发送的URL post.php
这样的脚本:
website.com/post.php?postid=53
我知道我可以使用$_SERVER['REQUEST_URI']
来获得原始URL在我的PHP脚本(AKA website.com/post/53/post-title/?anothervar=6
)以前被通过mod_rewrite的重写,然后就砍了字符串来获取可变添加,但我只是想知道是否有一个更优雅的解决方案,只使用mod_rewrite。
致谢,解决了这个问题。重写规则结束时的[R]是什么?在我的任何重写规则行结束时,我都没有。 – billmalarky
谢谢,我添加了这条评论,因为我忘了在上面的那个通知你:你的重写规则末尾是什么[R]?在我的任何重写规则行结束时,我都没有。 – billmalarky
这里是最好的答案。谢谢你 – Joshua