繁体   English   中英

.htaccess使用动态URL重定向

[英].htaccess redirects with dynamic URLs

我在重定向某些URL时遇到问题,旧站点中的URL带有?? 签名,不会重定向,其他所有URL都可以。 例如:OLD:/laser-alignment-resources/presentations.cfm?pres=diaphragm

新: http : //www.acquip.com/en/presentations/47-presentation-internal-laser-diaphragm-alignment

无法正常工作,我确定我做错了什么,但涉及.htaccess时我是n00b

所有网址都采用相同的格式,总共14个:

OLD:/laser-alignment-resources/presentations.cfm?pres = gas新: http ://www.acquip.com/en/presentations/48-presentation-gas-turbine-thermal-alignment

旧版:/laser-alignment-resources/presentations.cfm?pres = train新版: http ://www.acquip.com/en/presentations/49-presentation-complete-machine-train-alignment

任何帮助将不胜感激。

您对如何尝试在.htaccess文件中执行重定向的问题不清楚,因此,下次我建议您发布一些尝试过的代码示例,以便我们为您提供更多帮助容易。

根据您的Apache标记和您描述的问题,我将假设您正在使用mod_alias ,并尝试执行以下操作:

Redirect 301 /laser-alignment-resources/presentations.cfm?pres=diaphragm http://www.acquip.com/en/presentations/47-presentation-internal-laser-diaphragm-alignment

但是这不起作用,因为Redirect指令似乎仅检查请求的路径部分,而不检查查询字符串。

如果有可用的mod_rewrite ,则可以根据其查询字符串为需要重定向的URL设置重写规则。 看起来像这样:

RewriteEngine On

RewriteCond %{QUERY_STRING} =pres=diaphragm
RewriteRule ^laser-alignment-resources/presentations\.cfm$ http://www.acquip.com/en/presentations/47-presentation-internal-laser-diaphragm-alignment [R=301,L]

RewriteCond %{QUERY_STRING} =pres=gas
RewriteRule ^laser-alignment-resources/presentations\.cfm$ http://www.acquip.com/en/presentations/48-presentation-gas-turbine-thermal-alignment [R=301,L]

...等等。 您可以保留当前工作的Redirect语句,因为它们可以与这些规则并排使用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM