使用 .htaccess 或任何其他方法调整动态生成的链接?
我有一个电子商务网站(使用 ecommercetemplates 购物车 PHP 模板创建),在目录页面上有时会有一些页面在底部编号。例如,这些页面的链接采用以下形式:- /product.php?cat=27&pg=2
,尽管主页已映射到:- /widgets< /code> 在 .htaccess 文件中使用重写规则。
为了保持一致性和简单性,我希望页面如下:- /widgets?pg=2
。我在这个论坛中询问如何做到这一点,并找到了以下解决方案:-
RewriteRule ^widgets$ products.php?cat=27 [QSA]
问题是,尽管上述重写规则按我想要的方式工作,目录页面上的当前链接仍然指向,例如:- /product .php?cat=27&pg=2
。为了转到 /widgets?pg=2
,我必须在浏览器中输入此内容。
所以我的问题是:如何更改目录页面上动态生成的当前链接?是否可以在 .htaccess 中输入任何进一步的规则,或者是否有其他解决方案来解决此问题?以下是产品页面的 PHO 代码:- http://freetexthost.com/3ubiydspzm。
在上面的链接中,如果您搜索“writepagebar”,我认为这是完成“下一页”、“上一页”和“页码”的地方。
I have an e-commerce website (created with a ecommercetemplates shopping cart PHP template) and on the catalogue pages there are, at times, a few pages which are numbered at the bottom. The links to these pages are, for example, in the form:- /product.php?cat=27&pg=2
despite the main page having been mapped to:- /widgets
using a rewrite rule in a .htaccess file.
For the sake of consistency and simplicity, I would like the pages to be as:- /widgets?pg=2
. I asked in this forum how to do this and found the following solution:-
RewriteRule ^widgets$ products.php?cat=27 [QSA]
The problem is that despite the above rewrite rule working as I wanted, the current links on the catalogue page still point to, for example:- /product.php?cat=27&pg=2
. In order to go to /widgets?pg=2
, I have to enter this in the browser.
So my question is: How do I change the current links on the catalogue page, which are dynamically generated? Are there any further rules which can be entered in .htaccess or is there any other solution to this problem? The following is the PHO code for the product page:- http://freetexthost.com/3ubiydspzm.
In the link above, if you do a search for 'writepagebar', I think this is where the 'next page', 'previous page', and the 'page numbers' are done.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您有几个选择:
其中大多数需要的不仅仅是 .htaccess 重写规则。
Hack:(
这可能需要重写基础选项)
http://services.rrbits.com/products.php?cat=27&pg=2
(示例链接。)You have a couple of options:
Most of them require more than just .htaccess rewrite rules.
Hack:
(This might need the rewrite base option)
http://services.rrbits.com/products.php?cat=27&pg=2
(Example link.)