简体   繁体   中英

.htaccess from ModX to WordPress

Working on a project that requires a migration from ModX to WordPress.

The URL will need to change as follows:

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

Or we have some sites that might look like this

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

What I have tried so far:

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]

Place this rule just below RewriteBase line in your wordpress .htaccess :

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

This will perform following redirections with R=301

  • /finance-about to /finance/finance-about
  • /anything-here to /anything/anything-here

Try something like this:

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

Or:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM