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

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:

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

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. 🙂

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


More articles to check out

  1. You're not allowed to change a brake light in a new car?
  2. Unexpected surprise, Casio F201
  3. Why the Epiphone Explorer is better than the Gibson (for now)
  4. You should surround yourself in guitar luxury
  5. Forgotten Gibson: 1983 Map Guitar
  6. Casio MTP-V003, the one everyone missed
  7. Just for the look: Peavey Solo guitar amp
  8. Spacehunter, that '80s movie when 3D was a thing
  9. The Ice Pirates 1984
  10. A list of ridiculously accurate watches