How to fix 301 permalink redirect for funky structure -
i'm trying figure out how redirect permalink structure of old wordpress news portals, using funky structures needed google news , old search engines, crap.
for example, have:
mynewssite.xcom/2015/03/19/fnw14770_161419.php
where i'd rather have:
mynewssite.xcom/pretty-nameo-of-the-article-fnw14770/
i okay instead:
mynewssite.xcom/pretty-name-of-the-article-fnw14770_161419.php
my current wordpress permalink structure is:
/%year%/%monthnum%/%day%/fnw%post_id%_%hour%%minute%%second%.php
i need 301 redirect /%postname%/
or /%postname%-%post_id%/
, or in worst case senario, this:
%postname%-fnw%post_id%_%hour%%minute%%second%.php
i don't know how write rewrite expressions. have now, it's not working:
redirectmatch 301 ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/fnw(\d+)_%hour%%minute%%second%.php$ http://floridanewswire.com/?p=$4
%hour%%minute%%second%
won't work in .htaccess, meta information known wordpress. instead, try replacing rule matches 6 digits, such \d{6}
also, should remove unnecessary capture groups, escape forward sashes , dots, , use \d
instead of [0-9]
.
here fixed , simplified version of expression:
redirectmatch 301 ^\/\d{4}\/\d{2}\/\d{2}\/fnw(\d+)_\d{6}\.php http://floridanewswire.com/?p=$1
you should able change permalinks cleaner structure on settings > permalinks admin menu , have old permalinks redirected through htaccess rule.
Comments
Post a Comment