This section explains the regular expressions used in “Redirect Handling During URL Corrections,” providing part-by-part explanations and common usage examples. Please use this as a reference.
For information about redirects, please also refer to “Manage 301 redirects by Redirection”
Actual Conversion Example
Part-by-Part Explanation
Source URL: ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)
① ^/ “URL must start with /”
② ([0-9]{4}) = Year (YYYY) → Captured in $1
③ /([0-9]{2}) = Month (MM) → Captured in $2
④ /([0-9]{2}) = Day (DD) → Captured in $3
⑤ /(.*) = Slug portion (super important)
Capture Correspondence
| Group | Content |
|---|---|
| $1 | Year (YYYY) |
| $2 | Month (MM) |
| $3 | Day (DD) |
| $4 | Slug (Article Title) |
Target URL: /$4
Meaning
/, so it’s not needed hereActual Conversion Example
Basic Parts
Redirection Operation Rules
① URL with year/month/day → Slug only
WordPress permalink change (/%year%/%month%/%day%/ → /%postname%/)^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)/$4② Move an entire directory structure to a different location
/old-blog/xxx → /blog/xxx^/old-blog/(.*)/blog/$1③ Japanese URL → English slug (with sequential number)
^/ja/Japanese-title-([0-9]+)/ja/english-title-$1④ Remove index.php / index.html
^/(.*)/index\.(php|html?)$/$1/⑤ Remove trailing slash → Add trailing slash
^(.+[^/])$$1/⑥ http → https
^http://(.*)https://$1⑦ Upper-case URL → Lower-case URL
^/(.*[A-Z].*)/$1⑧ Redirect while ignoring query URLs
?utm_source=xxx^/some-page/?$/some-page/⑨ Bulk rescue for URLs generating massive 404s
^/tag/(.*)/blog/⑩ Catch both ja and en (multilingual)
^/(ja|en)/(.*)/$1/new-path/$2