Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-24-2011, 03:35 PM   PM User | #1
Tony M
Regular Coder

 
Join Date: Jun 2010
Posts: 132
Thanks: 8
Thanked 0 Times in 0 Posts
Tony M is on a distinguished road
Redirect Website

My website can be accessed from different URLs and IPs. For Example it can be accessed by:
mirror1.com/~mysite/
mirror2.com/~mysite/
123.123.123.123/~mysite/
mirror3.com/~mysite/

And (for an Unknown reason) My website can be accessed from many different URLs (and some that I do not even know their URLs)
Search engines begins to crawl some different url versions of My site, and begins to Ban My site....

BUT My main website that I want users to visit is: www.example.com

So My question is:
I want to redirect 301 (by using .htaccess) all requests from http://all-urls-and-ips/~mysite/ to http://www.example.com/ (that is My site). So how can I do this?

Any Suggestions Will Be Helpful
Tony M is offline   Reply With Quote
Old 02-25-2011, 08:54 AM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Try
Code:
RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:27 PM.


Advertisement
Log in to turn off these ads.