使用.htaccess重定向站点,但不包括两个以上的文件夹 [英] Redirect site with .htaccess but exclude two+ folders
本文介绍了使用.htaccess重定向站点,但不包括两个以上的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
根据此 answer ,您可以像这样从重定向中排除单个子文件夹:
According to this answer, you can exclude a single subfolder from a redirect like so:
RewriteEngine on
RewriteRule !^uploads($|/) http://example.com%{REQUEST_URI} [L,R=301]
我如何扩展它以包括两个或更多单独的子文件夹?
How would I expand that to include two or more separate subfolders?
推荐答案
您可以使用以下代码排除多个文件夹:
You can exclude multiple folders with the following code:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/test/
RewriteCond %{REQUEST_URI} !^/my-folder/
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
这将重定向所有未启动的请求
This will redirect all requests that don't start with the folder /test/ or /my-folder/ to newdomain.com.
来源:基于此处。
这篇关于使用.htaccess重定向站点,但不包括两个以上的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文