SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    htaccess redirection for 3 domains in same webserver host

    I have a webserver shared hosting and 3 domains pointing to it. I need a htaccess file that will redirect 3 domains to specific url with https
    Example: The domains are
    1. http://mydomain1.com
    2. http://mydomain2.com
    3. http://mydomain3.com

    I want that if someone types in http://mydomain1.com should redirect to https://mydomain1.com.index.php
    I want that if someone types in http://mydomain2.com should redirect to https://mydomain2.com/index.php
    I want that if someone types in http://mydomain3.com should redirect to http://mydomain3.com/package1.php (without https://)

    I have SSL for mydomain1.com and mydomain2.com, while mydomain3.com doesn't have a SSL.

    Please help me out and provide me a .htaccess file that I need to place in server root.
    I am a novice and do not have any idea.
    Thanks and regards in advance,
    Victor

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

    Ignoring the www's, eh?

    Code:
    RewriteEngine on
    RewriteCond %{HTTP_HOST} (mydomain1|domain2)\.com [NC]
    RewriteRule ^$ https://%1.com/index.php [R=301,L]
    
    RewriteCond %{HTTP_HOST} mydomain3\.com [NC]
    RewriteRule ^$ package1.php [L]
    That will do precisely what you asked for (except mydomain1.com.index.php which I assume was a typo). It does NOT enforce https on scripts on mydomain1 or mydomain2 but you didn't ask for that.

    As for more generic code, that can be found in my signature's link with other sample codes - you'll merely need to add the RewriteCond for your domain name for them to work ONLY on specific domains.

    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
  •