Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using Wordpress 3.1.3 as a full CMS, installed in the root directory of a domain. I have it setup using the built in options to have a static page as the home page, and then my blog at http://www.mydomain.com/blog.

What I would like is to have my single blog posts, category pages, archive pages, and tag pages, and any other blog-related pages have the "prefix" of /blog/ in their link structure. So a post URL would be www.mydomain.com/blog/post-title


Right now, I only have the category pages working correctly. This was accomplished by adding the following line to my .htacces file:

RewriteRule ^category/(.+)$ http://www.mydomain.com/$1 [R=301,L]

Then, I set the Category Base to "blog" on the Permalinks Settings page in Wordpress. This gives category pages the URL of: www.mydomain.com/blog/category-name (without removing the category prefix in .htaccess, they had the URL category/blog/category-name).


In an attempt to get this working for the other things I want it to work for, I set my Tag Base to "blog." I also made my Custom Permalink Structure: /blog/%postname% (as suggested by a few threads I've found searching on Google).

These settings give the URLs for the single blog posts, tags pages, and archive pages the URL structure I'm looking for. However, it makes them all lead to 404 errors.

I deleted my .htaccess file to ensure Wordpress was writing to it, and it is. If I remove the /blog/ from the permalink structure, everything works correctly, but I no longer have the URL structure I'm looking for.

I'm at a loss as to what I should do. I keep reading threads and guides saying this is as simple as adding /blog/ to the permalink structure, but so far it hasn't been nearly that simple.

I would be very grateful if anyone knows how I can get this to work.

.htaccess contents:

<IfModule mod_rewrite.c>
RewriteEngine On 
RewriteBase / 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule>
share|improve this question

2 Answers 2

up vote 0 down vote accepted

Go to Settings>Permalinks and add it to the permalink structures

share|improve this answer
    
That was one of the first things I tried, and was resulting in 404 errors. So I had it disabled for a few hours, and decided to try it again after reading your response. It's now working for my single post pages. I also got the category pages working again. That just leaves the tag pages and the archive pages that need the /blog/ in them. –  Preston Jun 5 '11 at 4:54
    
If you look at the page there is a spot for the tags as well. As for the archive pages are you talking about the the page that shows the list of articles, tags, categories, etc. or archived posts –  xLRDxREVENGEx Jun 5 '11 at 4:57
    
With the tags, if I add blog into the Tag Base area it gives me the correct URL structure "mydomain.com/blog/tag-name" but that page then gives me a 404 error. With the archives, I mean the page that shows the archived posts for a particular month. I would like the URL to be mydomain.com/blog/2011/05. That URL structure shows up when I click an archive link, but also gives a 404 error. And now I'm getting 404 errors for the single blog posts again. Could this be a plugin that's causing problems? –  Preston Jun 5 '11 at 4:58
    
Is your .htaccess setup right? –  xLRDxREVENGEx Jun 5 '11 at 5:00
    
I believe so, Wordpress adds in the rewrite rules any time I change them. Should there be anything in particular in there for something like this? –  Preston Jun 5 '11 at 5:01

You get 404 errors when you add "/blog/" to the custom permalink structure and then also add "/blog/" to the category base. It should only be added to one, the custom permalink structure.

If you leave your category base and tag base blank and just add "/blog/" to the front of the custom permalink structure to make it look like this "/blog/%postname% - this will get the desired result.

Your pages will look like this: domain.com/pagename/ Your post URL will look like this: domain.com/blog/postname Your category URL will look like this - domain.com/blog/category/postname

Hopefully this is useful...

share|improve this answer
1  
Good catch on adding to only one section. This solution also will add /blog/ to the category and archive pages which is good. This should really be the accepted answer. –  Ian Jun 6 at 20:44
    
I'm glad this method also applies to URL for the categories page. –  Edwin Yip Nov 4 at 5:11

protected by toscho Aug 11 '12 at 12:38

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.