简体   繁体   中英

Two different Query string redirect to same structure Htaccess

Please help me, I have two cases, I have a URL to redirect, for example

https://example.com/about-us and my rewrite rule is

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.

I want to redirect a different query string to this same structure like I have URL like

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

 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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