Ok, I’m very excited to give back to the WPMUDev community after all of the help you’ve given me so far! You guys have been awesome… and I want to be one who gives back… not just takes. :slight_smile: (But if you decide to thank me with a point or two, I certainly won’t mind!)
I’ve been racking my brains on how to get rid of that annoying /blog/ subdirectory that is inserted into permalinks automatically. You see, for those of you who don’t know… this is a rather brainless solution to a problem that comes up with multisite when using the subdirectory instead of subdomain structure… if you have a post called “blah blah” and your permalink is site.com/blahblah/… and then someone creates a new site (because you’re using Multisite) called blahblah… WP will try to create the new site under the dir blahblah under the root (site.com/blahblah). What that means is that you’ll have a conflict.
So rather than try to simply programatically search the db and make sure there are no conflicts and resolving such before creating the new site, the rather lazy solution was “oooh! Let’s just put all the blog content under a directory called blog!”. To me a better solution would have instead create all new SITES in a new subdir (maybe “site”:wink: instead of content… but whatever. I’m sure there’s a reason (other than a brainfart), but I don’t know what that reason may be.
Problem with this is, if you go from a regular to multisite setup… guess what happens to your posts. Yup. They originally pointed to /blahblah… but now it’s blog/blahblah. That can be a problem. I mean, I believe that WP probably automatically redirects it… though so far, my own personal test didn’t confirm that.
Me no likey. And there’s not much out there on the interweb for solutions… you can do a change in super-admin to the permalink structure. But it didn’t work for me AT ALL. There is also a plugin or two… again… no workey. So me no likey.
So, here’s how I fixed it… By the way… make sure the rest of your permalink structure is set up the way you like it before you proceed. (i.e. /%postname%/)
Using phpMyAdmin, I went into the wp_options table. In there are two entries… one with option_name called permalink_structure and the other called rewrite_rules. And then this is what I did:
1. Copy the current contents of the column called option_value. Paste this into a spreadsheet for safekeeping somewhere. That way, if you screw something up, you’ll have what you need to revert to the way it was before you made any changes. I’d also note option_id and option_name as well.
2. Edit the row, particularly the option_value column. Find wherever you see “blog/” and delete “blog/”. For the rewrite_rules row, I found it easier to copy the option_value and paste it into a text editor and do a search and replace. I replaced the “blog/” string with nothing (not a space… just leave the replace value blank). Of course, if this does nothing for you, then just do a find… and then physically delete that string “blog/” wherever you see it. If you do this in your text editor, copy the results and paste the new version back where you just where.
3. Just for kicks, do a commit; statement to make sure the change takes.
That should do it! Yup! Very easy… but just make sure to test it a few times… all your posts should now point to site.com/blahblah instead of the ugly site.com/blog/blahblah.
NOTE: If you ever go into the Permalink settings in your dashboard and make any changes and save them, THIS WILL UNDO WHAT YOU JUST DID (and come to think of it, would probably be a great way to back out if you wish to undo it). So just keep that in mind. If you make this change and want to keep it, don’t make any changes ever to the permalinks settings. If your permalinks are not set up the way you want to, be sure to do so BEFORE you make any changes to your database table.
If you have any questions, let me know in this thread. I’m not an expert and I say to do the above at your own risk… but so far it works for me. :wink:
If you found this post helpful, if you don’t mind… I’d love some points. I’m new here and I want to get to 1000 points someday so I can be an honorary lifetime member. But I know that I have to work hard and contribute alot to get there. I hope that this thread will benefit many!!!