0

从事需要从 ModX 迁移到 WordPress 的项目。

URL 将需要更改如下:

•         Currently (ModX):   http://www.acme.com/finance-about
•         Migrating to (WordPress):  http://www.acme.com/finance/finance-about/

或者我们有一些可能看起来像这样的网站

•         Currently (ModX):  http://www.acme.com/risk-management-about
•         Migrating to (WordPress):  http://www.acme.com/risk-management/risk-management-about/

到目前为止我已经尝试过:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/WPassets/
RewriteCond %{REQUEST_URI} !^/images/
RewriteRule ^([a-zA-Z_-]+)-([a-zA-Z_-]+)$ $1-$2/ [L]
RewriteRule ^([a-zA-Z]+)$ $1/ [L]
4

2 回答 2

1

RewriteBase将此规则放在您的行下方wordpress .htaccess

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)-([^/-]+)/?$ /$1/$0 [L,R=301]

这将执行以下重定向R=301

  • /finance-about/finance/finance-about
  • /anything-here/anything/anything-here
于 2013-09-30T10:16:25.637 回答
0

尝试这样的事情:

RedirectMatch 301 ^/([^/]+)-about$ /$1/$1-about/

或者:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)-about$ /$1/$1-about/ [L,R=301]
于 2013-09-30T07:19:31.847 回答