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/ ...
| |||||||
| Register | Forum Rules | FAQ | Donate | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Try this one HTML Code: RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.cormacmoylan\.com$ [NC]
RewriteRule .* http://www.cormacmoylan.com/ [L,R=301]
|
| |||||
| 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. |
| |||||
| So is it working now? |
| |||||
| 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. |
| |||||
| 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. |
| |||||
| 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 05:01 PM.. Reason: Spelling error |
| |||||
| |
| |||||
| 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! |
| Tags |
| file, htaccess, modrewrite, nowww, wordpress |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| | ![]() | |||
| | ![]() | |||