views:

40

answers:

4

I want to change my permalinks from /%year%/%monthnum%/%day%/%postname%/ to /%postname%/

but when I added the following to the .htaccess file, posts didn't redirect the way I thought they would:

RedirectMatch 301 /dddd/dd/dd/(.*) /$1

What do I need to put into my .htaccess file to make it work?

My site is http://SweatingTheBigStuff.com

A: 

You should use wordpress backend to update the permalinks (and if permissions allow, htaccess) is located here:

http://SweatingTheBigStuff.com/wp-admin/options-permalink.php

and in custom structure put

/%postname%/

Save it and you are done

Hansy
Will that change all current date links to point to the new formatted posts?
Daniel
yes, it will (will update wordpress permalink generator, and if permission enables to, htaccess file)
Hansy
Where in the code should I be looking? It's not as clear as I thought it would be. Here?<label><input name="selection" id="custom_selection" type="radio" value="custom" class="tog" <?php checked( !in_array($permalink_structure, $structures) ); ?> /> <?php _e('Custom Structure'); ?> </label> </th> <td> <?php echo $blog_prefix; ?> <input name="permalink_structure" id="permalink_structure" type="text" value="<?php echo esc_attr($permalink_structure); ?>" class="regular-text code" />
Daniel
You don't go into any code to change permalinks; that's changing WP core files, you'll break things and you'll loose your changes on an upgrade.
songdogtech
+1  A: 

You don't go into any code to change permalinks; that's changing WP core files, you'll break things and you'll loose your changes on an upgrade. It's much easier than that: go to Wordpress/Dashboard/Setings/Permalinks. If your .htaccess isn't writable, you'll get a warning.

And, using only the postname in permalinks is not recommended for performance reasons: Using only Postname in Permalinks « WordPress Codex

songdogtech
So what is the best permalink structure? I prefer not to use the date (I want to use the old post promoter plugin and the date makes it incompatible).
Daniel
+1  A: 

I think everyone is missing the point here - I think @Daniel has changed his permalinks, and now wants to redirect old permalinks.

The problem is your RedirectMatch regex is only matching a literal 'd', not digits.

Personally I would use this instead;

RedirectMatch 301 ^/[0-9]{4}/[0-9]{2}/[0-9]{2}/(.+)$ /$1

However, @songdogtech is right in saying that there are issues with using just the postname.

TheDeadMedic
You're right; missed that....
songdogtech
A: 

A relevant answer to TheDeadMedic,

You could use a plugin called Redirection to redirected your old permalinks to new permalinks.

But if you need to change your permalinks from the old version to a new version, then follow songdogtech's advice

Anraiki