SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Oct 2012
    Location
    Boise, ID
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Domain/page redirecting back and forth - best practice?

    I think I have this in the right place, so here's what I'm trying to do, and I'm not sure what the best option is:

    I'm finishing up a series of 4 websites: one primary and three secondary, each one on it's own domain. The company wants all sites to direct to the primary domain site, which will then link back to the others (each site relates to an organization in another state).

    For example:

    I want to go to www.state1.com and get redirected to www.primarysite.com, then that site will have a link that will go back to www.state1.com/index.php, and from there the site works normally (all links to that site's main page will reference index.php, not back to the primarysite.com).

    I have access to cPanel for each of these domains. I considered making home.php the default page, have that page redirect, then link back to index.php. But I'm hoping for a cleaner way to do it. Anyone have a thought? And did this even make sense?

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,604
    Mentioned
    19 Post(s)
    Tagged
    2 Thread(s)
    Whit,

    Loopy URLs? If the management that loopy?

    Well, it's not loopy if you've described it wrong, i.e., links direct to subdomains could be redirected to the primary/sub and that would actually make sense (although barely).

    Okay, specificity, if you please. Yes, I understand the need not to embarass your company so use primary.com and sub1.com, sub2.com, etc. Each sub#.com would have .htaccess files to redirect to the primary/sub# with the {REQUEST_URI} being retained. I'll help with the mod_rewrite code once the specification is correctly set.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Member
    Join Date
    Oct 2012
    Location
    Boise, ID
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks! I'll see if I can explain it better.

    Four domains totally (I haven't set them up in subdirectories...they're all on their own hosting accounts):

    www.primary.com
    www.sub1.com
    www.sub2.com
    www.sub3.com

    If a user goes to www.sub1.com, they are redirected to www.primary.com. Now this main website has general company-wide info as well as, on the main page, prominent links that go back to all three of the sub sites. The thinking is that they want users to go to the main site before heading to any of the sub sites (each sub site is location-based — different state for each).

    Here's what I did: I juts put an htaccess file in the root public directory with a DirectoryIndex home.php index.php in it. The home.php file that each of the sub domains have redirects the user to the primary.com website. That website then has links that will go to www.sub1.com/index.php, etc. Since the index.php file doesn't redirect the user, they can then navigate the website normally, and any internal links back to that site's home page goes to index.php.

    The one advantage to do it the way I did, that I can figure, is that employees or frequent visitors can just bookmark www.sub1.com/index.php (instead of www.sub1.com) and bypass the redirect to the main website. But I don't know if there's a big disadvantage to the way I set it up.

    If there's a compelling reason for me to do this another way, I'm all for it. (While I understand why they're doing it, it seems like more of an annoyance to their users.) Otherwise, any other suggestions would be greatly appreciated.

    Thanks DK!

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,604
    Mentioned
    19 Post(s)
    Tagged
    2 Thread(s)
    Whit,

    Whew! That helped immensely, thanks!

    Yes, it makes sense the way that you've done it IF each sub# manages their own domain (and you are not responsible for that).

    On the other hand, since you're asking, if you are responsible for every domain (primary and subs), I'd simply combine them into a "standard" cPanel master/addon set of domains (the addon domains also become subdomains). That would:

    • Allow you to manage all websites easier
    • Standardize CSS (page layout - the look and feel of the company across its state entities) by sharing files
      OMG! I can't believe the corporate IT would not enforce standardization across all units.
    • Standardize payment gateways
    • Standardize e-mail
    • Etc.


    You could still utilize your sub# domains in the same manner in which you're using home.php as the default sub# Home Page with index.php being their "real" Home Page but the standardization (and ease of access to each account) would make the "subdomain" approach of cPanel Addon Domains far simpler. It would also be less costly (a very minor factor) as you wouldn't need to hold four (or more) accounts. After all, the real cost of multiple domains is in the management which you are providing.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


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
  •