.htaccess 301重定向部分网址

Ibe*_*dia 1 apache .htaccess redirect

我正在重新设计我的网站,并在此过程中重组一些链接结构.

要执行永久重定向,我使用以下代码(.htaccess)

RedirectMatch permanent old-link($|\.html) http://thedomain.com/new-link.url
Run Code Online (Sandbox Code Playgroud)

我正在使用CMS并更改类别的链接会更改URL的路径,如下所示:

thedomain.com/old-category-link/old-article-url.html
Run Code Online (Sandbox Code Playgroud)

thedomain.com/new-category-link/old-article-url.html
Run Code Online (Sandbox Code Playgroud)

我应该如何编码(.htaccess)任何具有的URL的重定向

thedomain.com/old-category-link
Run Code Online (Sandbox Code Playgroud)

(即

thedomain.com/old-category-link/old-article.html
thedomain.com/old-category-link/old-article-2.html
thedomain.com/old-category-link/old-article-999.html
Run Code Online (Sandbox Code Playgroud)

)

thedomain.com/new-category-link/any-articles-old-url.html
Run Code Online (Sandbox Code Playgroud)

谢谢

Jon*_*Lin 5

不确定你要求重定向到什么,但它是这样的吗?

RedirectMatch permanent old-category-link(.*) http://thedomain.com/new-category-link$1
Run Code Online (Sandbox Code Playgroud)

如果有人要求,这将是如此:

  1. http://thedomain.com/old-category-link他们会重定向到http://thedomain.com/new-category-link
  2. http://thedomain.com/old-category-link/他们会重定向到http://thedomain.com/new-category-link/
  3. http://thedomain.com/old-category-link/article1.html他们将被重定向到http://thedomain.com/new-category-link/article1.html
  4. http://thedomain.com/old-category-link/article50.html他们将被重定向到http://thedomain.com/new-category-link/article50.html