edd_t Posted December 21, 2011 Share Posted December 21, 2011 Hello, Our company has decided to change name (how annoying) and want to make sure that the correct name is show in the browser URL. We currently have http://www.bessoholdings.co.uk and http://www.besso.co.uk When someone goes to http://www.bessoholdings.co.uk I need it to show as http://www.besso.co.uk From much google'fu all I have come up with is the following that doesnt work RewriteEngine on RewriteCond %{HTTP_HOST} !^www.bessoholdings.co.uk$ [NC] RewriteRule ^(.*)$ http://www.besso.co.uk/$1 [R] Anyone help at all? Thanks, Edd... Quote Link to comment Share on other sites More sharing options...
mawby Posted December 21, 2011 Share Posted December 21, 2011 This is what I use to redirect mkivsupra.net to http://www.mkivsupra.net RewriteCond %{HTTP_HOST} ^mkivsupra\.net RewriteRule ^(.*)$ http://www.mkivsupra.net/$1 [R=permanent,L] Quote Link to comment Share on other sites More sharing options...
SupraShaun Posted December 21, 2011 Share Posted December 21, 2011 Take the "!" out of the second line as *I think* at the moment that is saying "if the domain isn't this" then redirect. Alternatively you could leave the "!" in and change the domain to your primary, then anything that isn't your primary domain will redirect to it (this is probably the better way to do it, then you won't have to add a separate condition for each domain you have). I'm on my phone at the moment but will be able to give you the exact code when I get home if you need it Quote Link to comment Share on other sites More sharing options...
edd_t Posted December 22, 2011 Author Share Posted December 22, 2011 cheers guys, am still having no luck. took Mawby's and edited it with my URL and the site stopped working, whoops! lol I must have put something in wrong somewhere! so far have tried all of the follwing: RewriteCond %{HTTP_HOST} ^bessoholdings\.co\.uk$ [NC] RewriteRule ^/?$ "http\:\/\/www\.besso\.co\.uk" [R] RewriteCond %{HTTP_HOST} ^bessoholdings\.co\.uk$ [NC] RewriteRule ^/?$ "http\:\/\/www\.besso\.co\.uk" [L] RewriteCond %{HTTP_HOST} ^www.bessoholdings.co.uk$ [NC] RewriteRule ^(.*)$ http://www.besso.co.uk/$1 [R] RewriteCond %{HTTP_HOST} !^www.besso.co.uk$ [NC] RewriteRule ^(.*)$ http://www.bessoholdings.co.uk/$1 [L] RewriteCond %{HTTP_HOST} ^bessoholdings\.co\.uk$ [NC] RewriteRule ^/?$ "http\:\/\/www\.besso\.co\.uk" [L] But still no luck. Quote Link to comment Share on other sites More sharing options...
edd_t Posted December 22, 2011 Author Share Posted December 22, 2011 this is also in my .htaccess script, would that make a difference? perhaps the Authname part?? order deny,allow deny from all allow from all order deny,allow deny from all AuthName bessoholdings.co.uk AuthUserFile /home/********/public_html/_vti_pvt/service.pwd AuthGroupFile /home/********/public_html/_vti_pvt/service.grp Quote Link to comment Share on other sites More sharing options...
stevie_b Posted December 22, 2011 Share Posted December 22, 2011 Would a 301 server-side redirect be more appropriate? Possibly not, just a thought. Have you tried something like this? --> RewriteEngine on RewriteRule www\.bessoholdings\.co\.uk www.besso.co.uk I don't know the performance effect of using the rule to filter the domain substitution rather than using a RewriteCond. It might not be best practise but I can't see how it wouldn't work. If it works, it'll at least confirm that Apache's rewrite module is compiled in and functional. It shouldn't make any diffference but I noticed mawby's code didn't have a dollar end-of-string marker at the end of the RewriteCond filter, whereas all your attempts in post #4 do. Hence, maybe try this: RewriteEngine on RewriteCond %{HTTP_HOST} ^www.bessoholdings.co.uk RewriteRule ^(.*)$ http://www.besso.co.uk/$1 Quote Link to comment Share on other sites More sharing options...
SupraShaun Posted December 22, 2011 Share Posted December 22, 2011 Try this: RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.besso\.co\.uk$ [NC] RewriteRule ^(.*)$ http://www.besso.co.uk/$1 [R=301,L] Also the fact that bessoholdings.co.uk seems to be password protected may not be helping things. Quote Link to comment Share on other sites More sharing options...
David P Posted December 22, 2011 Share Posted December 22, 2011 Maybe Aunt Besso's cardboard puddings have beaten you to it. Quote Link to comment Share on other sites More sharing options...
edd_t Posted December 22, 2011 Author Share Posted December 22, 2011 thanks guys, Stevie_b your 2nd bit of code has worked perfectly cheers for taking the time to help. Edd.. Quote Link to comment Share on other sites More sharing options...
stevie_b Posted December 22, 2011 Share Posted December 22, 2011 Pleasure. Quote Link to comment Share on other sites More sharing options...
edd_t Posted December 22, 2011 Author Share Posted December 22, 2011 lol wierd side affect of all this, we can no longer browse the website from inside our company network! oh my god i hate DNS!!! although it works fine outside! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.