使用 .htaccess 附加参数
我正在与 htaccess 重写命令作斗争,
我所拥有的是
RewriteCond %{HTTP_HOST} ^www.mywebsite.co.uk$
RewriteCond %{REQUEST_URI} !^/subfolder/
RewriteRule ^(.*)$ /subfolder/
我有几个 URL 转到同一文件夹,其中一些重定向到子文件夹,然后运行不同的模板。但是,我还需要在重定向的每个页面的末尾附加一个参数,例如?template=2
我不能手动将其添加到末尾,因为有些页面已经有参数,例如/?product=1 - 所以第二个参数需要有&标志不是?符号。
任何帮助表示赞赏
i'm struggling with an htaccess rewrite command
what I have is
RewriteCond %{HTTP_HOST} ^www.mywebsite.co.uk$
RewriteCond %{REQUEST_URI} !^/subfolder/
RewriteRule ^(.*)$ /subfolder/
I have a few URLs going to the same folder, some of them redirect to subfolders, which then run different templates. However, I also need to append a parameter to the end of every page that is redirected, eg, ?template=2
I can't just add it to the end manually, because some pages already have parameters, eg /?product=1 - so the second parameter needs to have the & sign not the ? sign.
Any help appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需在规则末尾添加 QSA 标志:
You just need to add the QSA flag on the end of your rule: