简体   繁体   English

两个不同的查询字符串重定向到相同的结构 Htaccess

[英]Two different Query string redirect to same structure Htaccess

Please help me, I have two cases, I have a URL to redirect, for example请帮帮我,我有两种情况,我有一个 URL 来重定向,例如

https://example.com/about-us and my rewrite rule is https://example.com/about-us我的重写规则是

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?pageName=$1 [QSA,L]

and it is working perfectly for all pages with query pageName.它适用于所有带有查询 pageName 的页面。

I want to redirect a different query string to this same structure like I have URL like我想将不同的查询字符串重定向到相同的结构,就像我有 URL 一样

https://example.com/index.php?filter=latest

and I want to redirect this to the same format like above for about us page eg我想将它重定向到上面关于我们页面的相同格式,例如

https://example.com/latest

how it can be possible?怎么可能? please help me, thanks请帮助我,谢谢

You can't use same format or URI pattern for two rules, you can however change your second URL format to look something like https://example.com/second/latest here second can be any word you want add in the rule's pattern您不能对两个规则使用相同的格式或 URI 模式,但是您可以将第二个 URL 格式更改为类似于https://example.com/second/latestsecond可以是您想要添加到规则模式中的任何单词

 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^second/([^/]+)/?$ index.php?filter=$1 [QSA,L]

Remember to put this rule at the top or before the existing one.请记住将此规则放在顶部或现有规则之前。

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

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