Mod_Rewrite/Permalink Changes
-
Hello,
I have been making some major changes to my sites structure and setup which caused me to have to make some changes to the permalinks and link structure. I thought it would be easy to add .htaccess redirect rules, but I’m running into a lot of problems. I am currently running the latest version of WordPress with the Network setting
I’ve tried following the rules here:
https://scott.yang.id.au/2007/02/change-wordpress-permalink/
But I don’t think its working correctly on Network setting. This is the results I’m getting:
When I click the old permalink:
https://www.domainname.com/subdirectory/20101228-the-top-10-nfl-news-stories-of-2010/
Sends me to here:
https://www.sitename.com/?name=the-top-10-nfl-news-stories-of-2010
These are currently the Rewrite rules I have in .htaccess:
RewriteCond %{HTTP_HOST} !^(www)\. [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.sitename\.com$ [NC]
RewriteRule (.*) https://www.sitename.com/%1/$1 [R=301]
RewriteRule /[0-9]{4}/[0-9]{2}/[0-9]{2}/([^/]+)/? /?name=$1 [R,L]I’ve also tried the following script:
<?php if (have_posts()) : while (have_posts()) : the_post(); $the_year = print the_time('jS'); $the_day = print the_time('F'); $the_month = print the_time('m'); //To get the slug, use this: $post_obj = $wp_query->get_queried_object(); $post_ID = $post_obj->ID; $post_title = $post_obj->post_title; $post_slug = $post_obj->post_name; //The put it back together: header('Location: https://www.sitename.com/subdirectory/'.$the_year.'/'.$the_month.'/'.$the_day.'/'.$post_slug.'/'); endwhile; endif; ?>
Please let me know if you have any questions.
Thanks
Grant
- The topic ‘Mod_Rewrite/Permalink Changes’ is closed to new replies.