Rewrite Subdomains

Discussion in 'Apache' started by jabz.biz, Jul 26, 2008.

  1. #1
    Hi guys,

    I have a question which I was not able to answer myself browsing the net.

    I have a domain for quite some time, which was parked with networksolutions. As you maybe remember, they generated subdomains for their clients domains and used it to spam search engines.

    Two weeks ago I took the domain to start a website. I have lot`s of trouble getting into the serps again. :( So far so bad. Now I realized that google still lists some of the subdomains generated by networksolutions. When I click the I get an errorpage, but it is not my errorpage. Now my question is, how can I redirect the non-working subdomains to my custom errorpage? Because if I just redirect to the 404 error page I create a header status 200 (OK).

    So far my htaccess only contains the following:

    # alsways use the prefix www.
    RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
    RewriteRule .* http://www.domain.com/ [L,R=301]
    # Custom Errorpages
    ErrorDocument 401 /401/
    ErrorDocument 403 /403/
    ErrorDocument 404 /404/
    ErrorDocument 500 /500/

    The errorpages for everything in the root of the domain work.
    Any ideas? Links or resources?
    Thank you very much in advance, Jab
     
    jabz.biz, Jul 26, 2008 IP
  2. buldozerceto

    buldozerceto Active Member

    Messages:
    1,137
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    88
    #2
    Try this
    alsways use the prefix www.
    RewriteCond %{HTTP_HOST} ^.*domain\.com$ [NC]
    RewriteRule .* http://www.domain.com/ [L,R=301]
    # Custom Errorpages
    ErrorDocument 401 /401/
    ErrorDocument 403 /403/
    ErrorDocument 404 /404/
    ErrorDocument 500 /500/
     
    buldozerceto, Jul 26, 2008 IP
  3. mr_inisibile

    mr_inisibile Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    what about everything that was after the .tld part?

    eg. if i had traffic going from blog.domain.tld/2003/12/30/post-title/

    how could i make www.domain.ltd/blog/2003/12/30/post-title/

    any ideas would be helpful!
     
    mr_inisibile, Jul 28, 2008 IP