.htacess file - anyone help?

By : Administrator
Published 27th September 2010 |
Read latest comment - 30th September 2010

Bit stumped with this one, and managed to break the forum earlier.

We used to run on a different URL, which is now defunct, but I want to put a 301 redirect from mylocalforums.com to www.mylocalforums.com

Thought I had the syntax right, but as soon as I change it, the Forum (other than the index page) goes off the air

Using VBSEO, but from what I can see, it still references the .htaccess

Current .htaccess is:

RewriteEngine On
RewriteRule ^((urllist|sitemap_).*.(xml|txt)(.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
RewriteCond %{REQUEST_URI} !(admincp/|modcp/|cron|vbseo_sitemap)
RewriteRule ^((archive/)?(.*.php(/.*)?))$ vbseo.php [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/(admincp|modcp|clientscript|cpstyles|images)/
RewriteRule ^(.+)$ vbseo.php [L,QSA]

RewriteCond %{HTTP_HOST} ^usabusinessforums.us$ [OR]
RewriteCond %{HTTP_HOST} ^www.usabusinessforums.us$
RewriteRule ^(.*)$ "http://www.mylocalforums.com$1" [R=301,L]


So surely I just need to replace the last 3 lines with:
RewriteCond %{HTTP_HOST} ^mylocalforums.com$ [nc]
RewriteRule ^(.*)$ "http://www.mylocalforums.com$1" [R=301,nc,L]


Added nc just for any case sensitive issues.

But If I save this, it doesn't work

Any apache gurus?

Steve Richardson
Gaffer of My Local Services
My Local Services | Me on LinkedIn
Comments
forum avatarBowen73
29th September 2010 6:47 PM
cant this be done via the hosts using the dns settings to divert all traffic to the www domain insted of using a 301 via the htaccess?

i.e. i can use either poshkitty.co.uk or Posh Kitty - Personalised Gifts for all the family for all occassions to get to my site

forum avatarBowen73
29th September 2010 6:50 PM
well the last comment didnt show right becuase it filled in the page name instead of the address...lol...

but anyways... try this:

Redirecting entire sites with 301

The 301 directive is quite powerful. You can redirect not just single files but entire sites, for example when changing domain names e.g.

[HTML]redirect 301 / http://www.you.com/[/HTML]

The first "/" indicates that everything from the top level of the site down should be redirected. As long as you are using the same paths and filenames, then this option is a very simple way to perform site redirection in the situation where you have only changed your domain name.

forum avatarBowen73
29th September 2010 7:01 PM
i have found something else that might help too for redirecting non-www to www:

[HTML]Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [L,R=301] [/HTML]

not sure if any of this will help though, but its worth a try

Redirecting entire sites with 301

The 301 directive is quite powerful. You can redirect not just single files but entire sites, for example when changing domain names e.g.

[HTML]redirect 301 / http://www.you.com/[/HTML]

Cheers mate, didn't think of that way, always thought the best way was from the .htaccess

i have found something else that might help too for redirecting non-www to www:

[HTML]Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [L,R=301] [/HTML]

not sure if any of this will help though, but its worth a try

Yup I might have to revisit the actual syntax of the redirect. Mine was last set up by the previous hosting company, when we moved URL's, but not sure why its http://www

More research needed me thinks!

Steve Richardson
Gaffer of My Local Services
My Local Services | Me on LinkedIn

This Thread is now closed for comments