.htaccess 中的重定向路径和 410 其他所有内容
Redirect paths in .htaccess AND 410 everything else
我有大约 15 条路径的列表,我想永久重定向到新域,包括主页。
但是,我希望不在此列表中的所有其他内容都为 410(消失)。这在 .htaccess 中是否可以不列出 all other URLs/Paths?
RewriteRule ^category1\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category2\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category3\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category4\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category5\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category6\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category7\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category8\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category9\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category10\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category11\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category12\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category13\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category14\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category15\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^$ https://NEWSITE.com/ [R=301,L]
您只需在现有重定向之后添加以下内容 即可为其他所有内容提供 410 Gone:
# 401 Gone for everything else
RewriteRule . - [G]
旁白:
RewriteRule ^category1\*$ https://NEWSITE.com/ [R=301,L]
这个正则表达式看起来不正确。正则表达式末尾附近的 \*
是文字 *
,因此这只会重定向 /categeory1*
(文字字符串)。这是故意的吗?
也许你是说 ^category1/.*$
?这与 ^category1/
相同。并匹配任何以 /catgeory1/
开头的 URL 路径。 (?)
我有大约 15 条路径的列表,我想永久重定向到新域,包括主页。
但是,我希望不在此列表中的所有其他内容都为 410(消失)。这在 .htaccess 中是否可以不列出 all other URLs/Paths?
RewriteRule ^category1\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category2\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category3\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category4\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category5\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category6\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category7\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category8\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category9\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category10\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category11\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category12\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category13\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category14\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^category15\*$ https://NEWSITE.com/ [R=301,L]
RewriteRule ^$ https://NEWSITE.com/ [R=301,L]
您只需在现有重定向之后添加以下内容 即可为其他所有内容提供 410 Gone:
# 401 Gone for everything else
RewriteRule . - [G]
旁白:
RewriteRule ^category1\*$ https://NEWSITE.com/ [R=301,L]
这个正则表达式看起来不正确。正则表达式末尾附近的 \*
是文字 *
,因此这只会重定向 /categeory1*
(文字字符串)。这是故意的吗?
也许你是说 ^category1/.*$
?这与 ^category1/
相同。并匹配任何以 /catgeory1/
开头的 URL 路径。 (?)