I am trying to setup a simple re-direct for my Wordpress Blog in my .htaccess file. What I want is if people visit: mydomain.co.uk Code (markup): they get re-directed to: www.mydomain.co.uk Code (markup): Has anyone got this working? Thanks in Advance
wp-admin/options-general.php change the "Site address (URL)" option located in Setting==>General (in wp admin panel)
Think this is what you're looking for. RewriteEngine on Options +FollowSymLinks RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [NC] RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L] Code (markup):
Thanks, has this been tested with Wordpress? The code I tried works fine with basic websites but not with Wordpress.
tbh, I hadn't tried it with Wordpress. No, it doesn't work. What about some of these plugins - maybe one of them will do the job you want? http://wordpress.org/extend/plugins/tags/canonical
Just use A Plugin Called "Redirection" !! That seems to be a powerful one!! But, One or the other way, some one will be bringing out the correct Htaccess Code here ~ExP~
I was nearly right. This was bugging me. Here's the code for Wordpress (tested btw). You need to replace the existing block of Wordpress code in your htaccess file with code below. Redirect www.domain to non-www. # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com$ [NC] RewriteRule ^(.*)$ http://yourdomain.com/$1 [R=301,L] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress Code (markup): and for non-www to www.domain # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [NC] RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress Code (markup): OR If you are comfortable editing the htaccess, just add the two lines under RewriteEngine On to the existing code. These: or these (depending on whether you want www. or not) see above: