Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2005
    Posts
    268

    Redirect domain ?

    Hi guys,

    I just bought a SSL certificate for my domain, let say my domain is domain.com, how do i redirect domain.com to https://www.domain.com when people type domain.com on their browser? or if someone type www.domain.com then it will redirect to https://www.domain.com ?

    Thanks

  2. #2
    Join Date
    Dec 2005
    Location
    Internet
    Posts
    1,337
    Quote Originally Posted by AndyJ View Post
    Hi guys,

    I just bought a SSL certificate for my domain, let say my domain is domain.com, how do i redirect domain.com to https://www.domain.com when people type domain.com on their browser? or if someone type www.domain.com then it will redirect to https://www.domain.com ?

    Thanks
    You could use mod_rewrite rules in your .htaccess file for URL redirection. Please try the rules (mentioned below) for that.

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^.*$
    RewriteRule ^/?$ https://domain.com [R=301,L]

    Let us know how it goes
    Senior Server Administrator

  3. #3
    Join Date
    Jan 2005
    Posts
    268
    Quote Originally Posted by linuxcares View Post
    You could use mod_rewrite rules in your .htaccess file for URL redirection. Please try the rules (mentioned below) for that.

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^.*$
    RewriteRule ^/?$ https://domain.com [R=301,L]

    Let us know how it goes
    Do i have to create .htaccess ? because i don't have .htaccess in that domain users (/home/userA/public_html)

    Thanks

  4. #4
    Join Date
    Apr 2000
    Location
    California
    Posts
    3,051
    Yes, you will need to create it if it doesn't exist.

    Anyway, that above example may create an endless loop of redirects.

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^(www\.)?yourdomain\.com$ [NC]
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^/?(.*)$ https://yourdomain.com/$1 [R,L]

    That will ensure it's a non SSL port for that domain (with or without the leading www.), and if it is, it will redirect them to the secure URL, without the risk of a loop.

    Feel free to put in whatever code you want, how it'll redirect, and if it will carry over any other part(s) of the URL, etc.

  5. #5
    Join Date
    Jan 2005
    Posts
    268
    Thanks alot, it works now

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •