Irish SEO,  Marketing & Webmaster Discussion

 
Make money - save the planet!

Wordpress .htaccess file for no-www and mod-rewrite()

This is a discussion on Wordpress .htaccess file for no-www and mod-rewrite() within the Blogs & Blogging forums, part of the Webmaster Discussion category; I currently have this as my .htaccess file for WP Code: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /blog/ ...


Go Back   Irish SEO, Marketing & Webmaster Discussion > Webmaster Help > Webmaster Discussion > Blogs & Blogging

Register Forum Rules FAQDonate Members List Calendar Search Today's Posts Mark Forums Read


Notices

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-03-2007, 12:09 AM
Cormac's Avatar
Cormac Moylan
 
Join Date: Jan 2006
Location: Baile Ath Cliath / Corcaigh
Posts: 1,218
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Cormac is a splendid one to beholdCormac is a splendid one to beholdCormac is a splendid one to beholdCormac is a splendid one to beholdCormac is a splendid one to beholdCormac is a splendid one to beholdCormac is a splendid one to beholdCormac is a splendid one to behold
Send a message via AIM to Cormac Send a message via MSN to Cormac Send a message via Yahoo to Cormac Send a message via Skype™ to Cormac
Default Wordpress .htaccess file for no-www and mod-rewrite()

I currently have this as my .htaccess file for WP
Code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>

# END WordPress
I want to be able to enforce no-www on the entire domain. I have added
Code:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^cormacmoylan.com$ [NC]
RewriteRule ^(.*)$ http://cormacmoylan.com/$1 [L,R=301]
to a .htaccess file within the root of my site but it doesn't enforce no-www within the blog folder. How should I edit the .htaccess file within my blog folder to enforce no-www?

Many thanks
__________________
my blog | Apple Mac Blog | Indie Music Blog | *
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 06-03-2007, 11:49 AM
Hardcore Geek
 
Join Date: Aug 2006
Location: Dublin
Posts: 1,028
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Gavin has a spectacular aura about
Default

Try this one

HTML Code:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.cormacmoylan\.com$ [NC]
RewriteRule .* http://www.cormacmoylan.com/ [L,R=301]
__________________

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 07-03-2007, 02:30 PM
Cormac's Avatar
Cormac Moylan
 
Join Date: Jan 2006
Location: Baile Ath Cliath / Corcaigh
Posts: 1,218
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Cormac is a splendid one to beholdCormac is a splendid one to beholdCormac is a splendid one to beholdCormac is a splendid one to beholdCormac is a splendid one to beholdCormac is a splendid one to beholdCormac is a splendid one to beholdCormac is a splendid one to behold
Send a message via AIM to Cormac Send a message via MSN to Cormac Send a message via Yahoo to Cormac Send a message via Skype™ to Cormac
Default

Thanks gavin, but the issue I was encountering was combining the code from the modrewrite() code with the no-www code. It was getting all screwy on me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 08-03-2007, 08:34 PM
blacknight's Avatar
Web Slave
 
Join Date: Jan 2006
Location: Ireland
Posts: 6,265
blacknight is a splendid one to beholdblacknight is a splendid one to beholdblacknight is a splendid one to beholdblacknight is a splendid one to beholdblacknight is a splendid one to beholdblacknight is a splendid one to beholdblacknight is a splendid one to behold
Send a message via ICQ to blacknight Send a message via AIM to blacknight Send a message via MSN to blacknight
Default

So is it working now?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 08-03-2007, 10:10 PM
daviddoran's Avatar
Wannabe Geek
Recent Blog: Joost
 
Join Date: Aug 2006
Location: Meath, Ireland
Posts: 342
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
daviddoran will become famous soon enough
Default

I think you need the no-www code in httpd.conf because once the server gets to your .htaccess it has already chosen what domain/subdomain to use.
Httpd.conf lets Apache know ahead of time so it can redirect the domain request, not just at the folder/file level. AFAIK.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 10-03-2007, 06:36 PM
niall's Avatar
Hosting Caretaker
 
Join Date: Jan 2007
Location: Carlow
Posts: 63
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
niall will become famous soon enough
Send a message via ICQ to niall Send a message via MSN to niall
Default

Cormac,
I have that setup on my blog now, and have no major issues. The .htaccess in my wordpress folder is now as follows:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^blog.moybella.net$ [NC]
RewriteRule ^(.*)$ http://blog.moybella.net/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

In my vhost entry, blog.moybella.net is the ServerName and the ServerAlias is "www.blog.moybella.net blog.moybella.com www.blog.moybella.com"

Niall.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 14-03-2007, 03:48 PM
johnmryan's Avatar
Coder
 
Join Date: Mar 2007
Location: Dublin
Posts: 64
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
johnmryan will become famous soon enough
Send a message via MSN to johnmryan
Default

Is there are reason one would do this... just wondering?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8 (permalink)  
Old 14-03-2007, 03:55 PM
niall's Avatar
Hosting Caretaker
 
Join Date: Jan 2007
Location: Carlow
Posts: 63
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
niall will become famous soon enough
Send a message via ICQ to niall Send a message via MSN to niall
Default

Quote:
Originally Posted by johnmryan View Post
Is there are reason one would do this... just wondering?
Use Of www

Also, having more than one domain pointing at your site without a 301 redirect can dilute your pagerank as I understand it.

Last edited by niall; 14-03-2007 at 04:01 PM. Reason: Spelling error
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9 (permalink)  
Old 19-03-2007, 11:32 PM
niall's Avatar
Hosting Caretaker
 
Join Date: Jan 2007
Location: Carlow
Posts: 63
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
niall will become famous soon enough
Send a message via ICQ to niall Send a message via MSN to niall
Default

Looks like there is a wordpress plugin for doing this:

No WWW « Extend › Plugins
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10 (permalink)  
Old 20-03-2007, 08:31 AM
Cormac's Avatar
Cormac Moylan
 
Join Date: Jan 2006
Location: Baile Ath Cliath / Corcaigh
Posts: 1,218
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Cormac is a splendid one to beholdCormac is a splendid one to beholdCormac is a splendid one to beholdCormac is a splendid one to beholdCormac is a splendid one to beholdCormac is a splendid one to beholdCormac is a splendid one to beholdCormac is a splendid one to behold
Send a message via AIM to Cormac Send a message via MSN to Cormac Send a message via Yahoo to Cormac Send a message via Skype™ to Cormac
Default

sweet, i never had a chance to check the code you supplied but i came across a wordpress blog that i setup which forces no-www and also uses mod rewrite...the answer is never too far away!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
file, htaccess, modrewrite, nowww, wordpress

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT +1. The time now is 08:43 AM.


Powered by: vBulletin Version 3.7.3, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
Hosted in Ireland by Blacknight - Test your ISP |Irish Hosting Directory| Armchair.ie|Logo by Eden Web Design|Avatars by Afterglow |Latest Blog Entries | VPS HostingAd Management by RedTyger

Search Engine Friendly URLs by vBSEO 3.2.0