rich menga books gear search about contact
***Secret FSR Fender guitars? Yes, they exist, and they're right here

Amazon links are affiliated. Learn more.

wordpress subdirectory trailing slash problem - FIXED

(Warning: Computer geeky post.)

I'm writing this here for my personal reference just in case I ever had to do this crap again.

Situation: I wanted what's called a "forced www" on all parts of this web site. Some say www is deprecated. I think those people are full of crap (else why would Google do it?)

So I added an .htaccess redirect in the public root of this domain. If I type my domain in a browser, it auto-changes it to have the www in it just like it's supposed to.

My WordPress installation happens to reside in a subdirectory, blog.

Even with the .htaccess redirect, WordPress insists on not adding the www to the web address.

I scoured the internet looking for a solution to this, because no matter what I did, if I typed in my domain with /blog after it, no www would show up. Bleah.

I finally found a solution.

Don't use an .htaccess file in the WordPress subdirectory at all. Put everything in your public root .htaccess instead.

This is what I have now:

# FORCE WWW
RewriteEngine on
RewriteCond %{HTTP_HOST} ^[my domain here].com [NC]
RewriteRule ^(.*)$ http://www.[my domain here].com/$1 [L,R=301]

# WORDPRESS
Rewritebase /blog
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]

...and it works. Whether I use a slash or not (such as [my domain].com/blog without the trailing slash,) the www now shows up like it's supposed to.

Yay. 🙂

image
A classy guitar t-shirt for classy people

image
Best ZOOM R8 tutorial book
highly rated, get recording quick!

070905

More articles to check out

  1. Where can a middle aged guy get plain sneakers these days?
  2. An HSS guitar I can actually recommend
  3. The 1,000 year disc, M-DISC
  4. The watch you buy when your smartwatch breaks
  5. This is the cheapest way to get guitar picks
  6. This is the Squier I'd buy had I not just bought one
  7. Plywood might be one of the best electric guitar tonewoods
  8. Why isn't The Whoopee Boys a cult classic?
  9. And then there were the right two
  10. Squier Sub-Sonic, the 24 fret baritone guitar from 20 years ago