gpt4 book ai didi

regexp + modrewrite 就可以了

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:35:11 24 4
gpt4 key购买 nike

我正在尝试将旧的 Google 缓存链接重定向到我们的新网站。所以它在我的正则表达式编辑器中有效但在我的 htacess 文件中无效?

第一条规则似乎有效,但第二条规则无效。我在规则之上留下了示例。

# Legacy site redirects
# For homes home and search:
# www.site.ie/results_lost_found.html?search_type=lost_found&ad_type=&location_id=&x=31&y=12
RewriteRule ^results_lost_found|results_home(.+)search_type=lost_found(.*)$ lost_found [NC,R=301,L]
# www.site.ie/results_home.html?search_type=for_home&pet_type_id=&location_id=&x=14&y=10
RewriteRule ^results_lost_found|results_home(.*)search_type=for_home(.*)$ for_homes [NC,R=301,L]

最佳答案

您的所有规则都不起作用,因为 RewriteRule 仅匹配没有查询字符串的 URI。在 mod_rewrite 中你会做这样的事情:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} ^search_type=lost_found&ad_type=&location_id=&x=31&y=12$ [NC]
RewriteRule ^(results_lost_found|results_home)\.html$ /lost_found? [NC,R=301,L]

请注意使用查询字符串变量 %{QUERY_STRING} 来匹配您的查询字符串。

关于regexp + modrewrite 就可以了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15862675/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com