[英]Htaccess Redirect a folder and exclude two subfolders
I can't figure our RewriteRule so I've tried RedirectMatch. 我找不到我们的RewriteRule,所以我尝试了RedirectMatch。 I need to match to a folder /2018/
and all other sub-folders but I do not want to redirect /2018/speakers/
or /2018/events/
我需要匹配到文件夹/2018/
和所有其他子文件夹,但我不想重定向/2018/speakers/
或/2018/events/
RedirectMatch 301 ^/2018/$^(speakers|events)($|/) https://example.com/north-america
Doesn't seem to work and I really can't figure out how to exclude after an include. 似乎没有用,我真的不知道在包含之后如何排除。 Thanks for any help! 谢谢你的帮助!
If it must be Rewrite Rule here is the rest of the top portion. 如果必须是“重写规则”,则这是顶部的其余部分。 I need to do this for multiple years like 2017, 2016 etc so maybe this is the best way to do it. 我需要在2017、2016等年份进行多次操作,所以也许这是最好的方法。
# Force https
RewriteCond %{HTTP:X-Pagely-SSL} off
RewriteRule ^(.*)$ https://example.org/$1 [R=301,L]
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
You can use RewriteCond
to exclude some URLs 您可以使用RewriteCond
排除某些URL
RewriteCond %{REQUEST_URI} !^/2018/(speakers|events)
RewriteRule ^/?2018/(.+) https://example.com/north-america/$1 [R=301,QSA,L]
Line 1: if the request uri is not starting with /2018/speakers
or /2018/events
第1行:如果请求uri不是以/2018/speakers
或/2018/events
开头
Line 2: if the request uri is starting with /2018/
, then redirect to https://example.com/north-america/
permanently. 第2行:如果请求uri以/2018/
开头,则永久重定向至https://example.com/north-america/
。 $1
is the backreference to (.+)
. $1
是对(.+)
的反向引用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.