我想将所有 URL 从一个域重定向到另一个域。一些旧的 URL 有新的对应项,其中包含要重定向到的特定页面。所有其他 URL 应重定向到新域的主页。
但我不想重定向sitemap.xml. 所以我做了这样的例外(来自这里):
RewriteCond %{REQUEST_URI} !^/sitemap.xml?$
Run Code Online (Sandbox Code Playgroud)
但这不起作用。
这是我的完整代码:
RewriteEngine on
# exception for the sitemap:
RewriteCond %{REQUEST_URI} !^/sitemap.xml?$
# specific redirects:
Redirect 301 /old-page https://www.new-domain.com/
# catch the rest:
RedirectMatch 301 ^/ https://www.new-domain.com/
Run Code Online (Sandbox Code Playgroud)
有什么不对?