简体   繁体   中英

Redirect old wordpress URLs articles to new website and new permalinks URLs structure

I am making a new website to replace an existing website. And we are not keeping the previous permalink structure : see below
OLD URL = http www .domain.com/article.php?ID=3242
NEW URL = http www .domain.com/author/post-name

So we want to redirect the old urls to the new ones. How could I do that easily in the htaccess file ?

I tried redirect 301 but does not work.
RedirectMatch 301 ^/article.php?ID=3242 http://www.domain.com/author/post-name

RedirectMatch won't match the query string (the part after the ? ). This article explains a bit more, but this should work:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/article\.php$
RewriteCond %{QUERY_STRING} ^ID=3242$
RewriteRule ^(.*)$ http://www.domain.com/author/post-name [R=302,L]

Note that I changed it to a 302 redirect while you're testing; I'd only change it to a 301 once you're sure you've got it right (to avoid browsers caching incorrect redirects).

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