简体   繁体   中英

Redirection with Apache2 query_string with square brackets

I have a URL like

http://domain.net/documents?f[author]=43

Which should be redirected to

http://domain.net/documents/author/43

What I have so far is

RewriteEngine On    
Rewritebase /documents
RewriteCond %{query_string} f([^/]+)=(.*)$ [NC]
RewriteRule (.*) author/%2? [R=301,L]

However, this redirects all URLs, including http://domain.net/documents/author/43?page=1 back to http://domain.net/documents/author/43 when I just need to replace the "?f[author]=" part with "/author/"

RewriteEngine On    
Rewritebase /documents

RewriteCond %{ENV:REDIRECT_STATUS} !200
RewriteCond %{query_string} f([^/]+)=(.*)$ [NC]
RewriteRule (.*) author/%2? [R=301,L]

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