The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Redirect cpanel temporary url to main site

Discussion in 'General Discussion' started by elite, Mar 31, 2010.

  1. elite

    elite Registered

    Joined:
    Apr 24, 2005
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    My site is getting indexed by search engines at both domain.com and hostname.com/~domain

    Is there a way to set up a redirect so that anyone arriving at hostname.com/~domain will get a perminent redirect to domain.com?

    Any help much appreciated!

    Cheers

    Nick
     
  2. gratos

    gratos Registered

    Joined:
    Mar 31, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    You should create a ".htaccess" file in the root of your old domain and place the following code inside:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

    Please REPLACE www.newdomain.com in the above code with your actual domain name.
     
  3. elite

    elite Registered

    Joined:
    Apr 24, 2005
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Sorry, I probably wasn't clear.

    While the domain propergated from the old host to the new I redirected the old server to hostname/~domain (the new server), now I want any requests on the new server that arrive at hostname/~domain to be redirected to domain.com.

    I am mostly concerned about duplicate content for search engines as I'm now being indexed on both hostname/~domain and domain.com

    Thanks for the response

    cheers

    Nick
     
  4. MySitesOnline

    MySitesOnline Active Member

    Joined:
    Mar 24, 2003
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    Anyone have a solutions for this?
     
  5. Meebox

    Meebox Registered
    PartnerNOC

    Joined:
    Dec 2, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Denmark
    cPanel Access Level:
    Root Administrator
    Bump - I'm also looking for an answer. Anyone?

    /a
     
  6. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    The best solution is to not allow temporary urls anymore at all if everything has propagated. You should enable mod_userdir protection in WHM to disallow requests to that url, since you aren't gauging bandwidth if they come in at that url to that account. Bandwidth instead goes to the main server hostname and not the user's account.
     
  7. netshine

    netshine Member

    Joined:
    Dec 5, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    I want to allow the temporary URL domain.com/~username for most accounts, but just redirect from there to the live domain on a single website (so cPanelTristan's solution is not a good one for me). In case it helps anyone else, I found the following mod_rewrite redirect (in .htaccess) worked for me:

    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{REQUEST_URI} /~username
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]
     
Loading...

Share This Page