[英]Redirect all files in folder to another folder - keep queries intact
I'm trying to redirect all files within a folder to another folder using htaccess. 我正在尝试使用htaccess将文件夹中的所有文件重定向到另一个文件夹。 Each file may or may not have a query string.
每个文件可能有也可能没有查询字符串。 And that query string may vary.
该查询字符串可能会有所不同。
Example: 例:
should redirect to: 应该重定向到:
(The folder names "articles" plural became "article" singular.) (文件夹名称“ articles”复数变为“ article”单数。)
This seems a rather simple thing to do without the query string for example 例如,如果没有查询字符串,这似乎很简单。
RewriteRule ^articles/(.*)$ /article/$1 [L,NC]
... but apparently I must use "rewritecond" when dealing with query strings and I can't find any online example of how to forward from one folder to another while keeping any/all query strings intact. ...但是显然我在处理查询字符串时必须使用“ rewritecond”,而且我找不到任何在线示例,说明如何在保持任何/所有查询字符串不变的情况下从一个文件夹转发到另一个文件夹。
I think that there needs to be a condition matching any and all query strings, eg: 我认为需要有一个条件来匹配所有查询字符串,例如:
RewriteCond %{QUERY_STRING} .
... but then it falls apart, because this certainly doesn't work: ...但是后来它分崩离析,因为这肯定行不通:
RewriteRule ^$ www.example.com/articles/$1 [QSA,R,L]
您可以使用以下重定向:
RedirectMatch 302 ^/articles/(.+)$ /article/$1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.