Setting up redirects using .htaccess file
-
I wonder if someone could help me with setting up a redirect on my site? I am looking to add a redirect so the non www. version of the site redirects to to www. version of the site.
My site already has a .htaccess file with the following code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule># END WordPress
I have tried adding a separate .htaccess file with the following code but it didn’t work:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domainname.com
RewriteRule (.*) http://www.domainname.com/$1 [R=301,L]I have also tried combining the 2 files with the following code but that didn’t work either:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domainname.com
RewriteRule (.*) http://www.domainname.com/$1 [R=301,L]# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule># END WordPress
What am I doing wrong? Thanks in advance for any help.
[No bumping. If it’s that urgent, consider hiring someone.]
The topic ‘Setting up redirects using .htaccess file’ is closed to new replies.