Results 1 to 4 of 4

Thread: 301 redirect on subdomains

  1. #1
    Join Date
    Jan 2009
    Posts
    35

    301 redirect on subdomains

    Hello everybody

    I put the following code to my htaccess file on my main domain.

    Line number On/Off
    Code: Select all
    Options +FollowSymlinks
    RewriteEngine on
    rewritecond %{http_host} ^domain.com [nc]
    rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

    My problem is with my sub domain.because it defined as a separate site to my main domain by search engines, am curious to add a htaccess file to that subdomain.but i would like the subdomain.domain.tld to be the visible url for the subdomain only, instead of it rewriting to domain.tld/subdomain. hoping that someone could really understand my situation give necessary advice to resolve the issue..

    any help should be brilliant and greatly appreciated.
    thanks for reading me

  2. #2
    Join Date
    Feb 2008
    Posts
    2,635

    Re: 301 redirect on subdomains

    If you are just trying to redirect better locate to the index files of both of those pages and you can put a meta redirect right there.
    <META http-equiv="refresh" content="2; URL=http://www.yoursite.com/">
    The 2 being how many seconds before the forward.also any files on a subdomain effected by this .htaccess that do not have an .extention and do not end in a / will be rewritten to www.example.com/thecompletepath/

  3. #3
    Join Date
    Jan 2006
    Posts
    3,792

    Re: 301 redirect on subdomains

    I need to ask you few questions Is it the case that you want to redirect *all* subdomains to your main domain,you having more files?If it has considerable number, but not all, are there more that you want to redirect than that you want to keep? this things are really playing important role in this topic

  4. #4
    Join Date
    Apr 2008
    Posts
    3,424

    Re: 301 redirect on subdomains

    It depends on your server configuration, and the procedure currently in use to rewrite subdomain requests to those sub directories. but in the code, the first rule does not need to be altered, whether it is used in your top-level directory or duplicated in every subdomain's subdirectory.

    The second is basically to prevent an infinite loop when it interacts which the method currently used to rewrite subdomain requests to subdirectories. It is coded so that it only affects client requests for subdomain-subdirectories, and will not be invoked if the request for the subdirectory is produced by the server in response to a subdomain request.

Similar Threads

  1. Find the list of subdomains of a Web domain
    By EricTheRed in forum Tips & Tweaks
    Replies: 2
    Last Post: 11-03-2011, 04:46 AM
  2. Bandwidth counted double on subdomains in Cpanel
    By Galimberti in forum Software Development
    Replies: 5
    Last Post: 17-06-2010, 03:09 AM
  3. How to track multiple domains from subdomains
    By tecHAMMER in forum Networking & Security
    Replies: 3
    Last Post: 07-10-2009, 09:59 AM
  4. Replies: 5
    Last Post: 06-02-2009, 04:03 AM
  5. Domains/subdomains
    By Mark in forum Active Directory
    Replies: 5
    Last Post: 12-10-2008, 07:45 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,733,553.38106 seconds with 17 queries