Jun
13

WordPress no-www

Filed under: Asides, WordPress | Tags: | June 13th, 2006
Post

After being frustrated with mod_rewrite mojo, I wrote a quickie no-www plugin for WordPress that redirects people to the non-www version of your URLs, in the spirit of no-www.org.

59 Responses

Avatar

Rob | June 13th, 2006 @ 3:33 am

Hi Matt,

Thanks for wrapping this into a plugin. I’d implemented the no-www Apache script to solve a host of Ajax issues with my Wordpress install but it’s good to have a solution that works with WP’s existing .htaccess editing

Current score: 0
Avatar

Ken Savage | June 13th, 2006 @ 3:41 am

Good stuff Matt. Is there a way I can reverse this and have everyone coming from http://domain.com redirect to http://www.domain.com

Current score: 0
Avatar

Matthew | June 13th, 2006 @ 7:02 am

Hey, that’s handy - thanks!

Current score: 0
Avatar

Bonita in Pink | June 13th, 2006 @ 7:18 am

thank you!
I’m using this now and it works perfectly!
All I had to do was activate it.
That’s it!
It rocks!
I love easy plug-ins like that!
Thanks!

Current score: 0
Avatar

Ara Pehlivanian | June 13th, 2006 @ 8:27 am

Heh, DreamHost has a neat little util in the panel that lets you do exactly that. I’m proud to say I’ve been no-www for quite some time now!

Good idea to write a plugin though. I don’t think people realize how much of a hit they take in search engine ranking when they allow both www and no-www. Check out digg’s ranking vs. slashdot on http://populicio.us/fulltotal.html. Digg’s combined numbers easily beat out slashdot, but because its numbers are split due to www and no-www, it sits at 6th and 11th.

Current score: 0
Avatar

Jonathan | June 13th, 2006 @ 8:36 am

Awesome! I’ve had the mod_rewrite rule in my .htaccess for a couple months. I just installed the plugin and erased the mod_rewrite rule. Everything works flawlessly.

Current score: 0
Avatar

Paul Mitchell aka Libertus | June 13th, 2006 @ 9:09 am

I’ve been experimenting with a different approach: root-relative WordPress addresses.

The one downside I’ve found so far, and it’s minor, is that my RSS feed reader (Akregator) breaks the UA rules and doesn’t prepend the scheme/host to the relative URLs that now appear in the feed. I suppose I could force absolute URLs in the feed using a plugin.

Current score: 0
Avatar

David Hosier | June 13th, 2006 @ 9:12 am

Isn’t that what Mark’s plugin does?

Current score: 0
Avatar

Ron Pemberton | June 13th, 2006 @ 9:25 am

Does this do the same as the plug-in called Objection redirection? Found here; http://wordpress-plugins.biggnuts.com/objection-redirection-wordpress-plugin/

I have downloaded this plug-in, but haven’t activated it yet because I found your new plug-in. Obviously I would go with yours over someone else any day.

PS- could you also shed some light on this whole meta tag issue I’ve been reading on the net. The way I figure it, you are expert at all things WordPress; so if meta tags were a necessity, you would have built it all into WordPress to begin with.

Thanks!

Current score: 0
Avatar

Matt | June 13th, 2006 @ 9:44 am

Yep it looks exactly the same as those other plugins, except a little more bare. I should Google more! :)

Current score: 0
Avatar

Hoover | June 13th, 2006 @ 10:37 am

ummm… if DNS is setup properly, you don’t have to use w3 anyway… w3 is not “required”.

Current score: 0
Avatar

Matt | June 13th, 2006 @ 10:47 am

Hoover, it has nothing to do with DNS.

Current score: 0
Avatar

david | June 13th, 2006 @ 11:24 am

man, I thought it was just me who didn’t like the http://www….

Current score: 0
Avatar

Chris J. Davis | June 13th, 2006 @ 11:34 am

Methinks your plugin doth fail too much. Any link on your site I try to load that doesn’t have the www gives me a very silly 404 error.

Current score: 0
Avatar

Anonywww | June 13th, 2006 @ 11:35 am

Um…

http://photomatt.net/2006/06/13/wordpress-no-www/

404 Not Found
The resource requested could not be found on this server!

Current score: 0
Avatar

Matty | June 13th, 2006 @ 12:22 pm

Have you turned the plugin off? It doesn’t appear to be working on here!

http://www.photomatt.net/2006/06/13/wordpress-no-www/ gets to this page just fine but…

http://photomatt.net/2006/06/13/wordpress-no-www/ give a 404

Current score: 0
Avatar

Steve | June 13th, 2006 @ 12:49 pm

Don’t know if it is temporary, but at 19:47 BST (GMT+1) I get this:

http://photomatt.net/2006/06/13/wordpress-no-www/ = 404 not found

Current score: 0
Avatar

Matt | June 13th, 2006 @ 1:25 pm

Hey sorry guys, my site is messed up for another reason. When the password thing happened my site somehow got delisted from Google without the www, so I’ve been experimenting with changes to bring it back.

Current score: 0
Avatar

greg | June 13th, 2006 @ 3:38 pm

awesome! i have struggled with the www vs non-www issue for awhile.

Current score: 0
Avatar

Chris J. Davis | June 13th, 2006 @ 5:19 pm

Ah, good to know Matt.

Current score: 0
Avatar

Jim Mitchell | June 13th, 2006 @ 8:47 pm

Hot Dang! Just was I was trying to (unsucessfully) pull off via .htaccess last night. Thanks Matt! You ‘da man.

Current score: 0
Avatar

Mark Jaquith | June 13th, 2006 @ 10:47 pm

I wrote a plugin that does it both ways… that is, it enforces your yes-www or no-www preference as set in Options » General.

Enforce http://www. Preference

Current score: 0
Avatar

Michael | June 13th, 2006 @ 11:58 pm

Arggg….

http://www.whalesalad.com/2006/06/07/whats-up-with-these-urls/

Current score: 0
Avatar

Venu | June 14th, 2006 @ 2:17 am

Nice plugin..
But after I activated this plugin I noticed one problem.

If I try to setup my blog via a weblog client say Flock or Qumana, I am getting a error while providing the authentication information(User Name/Password) The HTTP status code is 301.

Even I tried to post a new blog from the already configured client and I was getting the same HTTP status.
I deactivated the No-WWW plugin and everything was working fine !!!

Probably you need to check on this.

Current score: 0
Avatar

Venu | June 14th, 2006 @ 2:24 am

Ooops ! I guess I gave a feedback too soon.
When registering the blog in the web log client if I give a “No-www” url its working fine :-)

Current score: 0
Avatar

gutielua | June 14th, 2006 @ 7:43 am

Appears this error:

It needs to qualify the send of referrers so that this works.

(Necesita habilitar el envío de referrers para que esto funcione.)

I close all windows, and star again and works, strange, do you?

Regards!

@

Current score: 0
Avatar

David | June 14th, 2006 @ 11:41 am

Arrrgggghhh, indeed.

Installed fine. (Except for a false error from WP “Sorry, you need to enable sending referrers for this feature to work.” Got the same error in two different browsers that have “sending referers” enabled.

But… checked back and the plugin reported itself installed and the no-www.org site reported my blog as a “Class B” compliant site.

Then, I becgan getting emails that my wp-comments-post.php page would not display. Yup. No comments. This plugin was the only change, so… went to deactivate it and… “Sorry, you need to enable sending referrers for this feature to work.” And this time, no deactivation.

Guess I have to nuke the thing via ftp and seek a plugin (or other method) that’ll work w/o hashing things up. Nice idea. Works fine except for the comments issue and the weird “Sorry, you need to enable sending referrers for this feature to work,” error that cropped up for the very first time after installing this plugin.

Current score: 0
Avatar

David | June 14th, 2006 @ 11:58 am

Yep. Just nuked the plugin via FTP and both issues are gone.

Current score: 0
Avatar

Jacques Marneweck | June 14th, 2006 @ 2:07 pm

That plugin is fantastic :) I just now need to get round to migrating away from Movable Type over to WordPress at somestage in the future.

Current score: 0
Avatar

Matt | June 14th, 2006 @ 3:32 pm

If you’re having problems, make user you change your URL under Options > General to not have a http://www.

Current score: 0
Avatar

Computer Guru | June 15th, 2006 @ 4:07 am

Whoah…
It’s doing the opposite for me.

http://neosmart.net/blog/ goes to http://www.neosmart.net/blog/

And in my options page there is no http://www.

Maybe it has to do with my blog being in a subdomain?

I had no issues with Mark’s plugin, I’m only using this one because it’s lighter on the server.

Current score: 0
Avatar

Computer Guru | June 15th, 2006 @ 4:07 am

Oops! I meant on a subfolder - not subdomain.

Current score: 0
Avatar

Otto | June 15th, 2006 @ 1:23 pm

While this plugin and other like it will indeed work, I really recommend using the .htaccess method instead, if you can get it to work.

It’s actually very simple to do. Go to http://no-www.org and scroll down the page until you find the post titled “Make your site Class B”. Copy that htaccess code into the .htaccess file at the root of your webpage. Change the “domain” to your own, obviously.

Done and done.

Current score: 0
Avatar

Aaron Brazell | June 20th, 2006 @ 3:53 pm

This plugin, while useful, needs to use implode() on $_GET in order to pass query string variables such as, I don’t know, s=

;)

Current score: 0
Avatar

Ken Savage | June 24th, 2006 @ 7:39 am

btw in my comment #2 I mentioned how to reverse this. You can find a new great plugin by Justin at:

http://www.justinshattuck.com/wordpress-www-redirect-plugin/

Current score: 0
Avatar

David | July 14th, 2006 @ 8:27 pm

I implemented the plug-in on two sites (one running WP2.0.1, the other 2.0.3) using two different (but fully working) themes, and I found that comments got broken on both sites, leading to a blank page of wp-comments-post.php. Deactivating the plug-in fixed comments immediately. Both sites were running php 4.4.2 if that might have an effect…

Current score: 0
Avatar

Courtney Tuttle | February 24th, 2007 @ 12:57 pm

Matt, you’re the man! I’ve been trying to figure out how to make this work for a few weeks. My host wouldn’t work with most of the options. This way works great. Thanks much.

Current score: 0