Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Regular Coder
    Join Date
    Sep 2004
    Location
    USA
    Posts
    314
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Forwarding non-www to www on http AND https

    Hi all, I am trying to forward an traffic that comes to http://mysite.com to http://www.mysite.com but I also need to forward https://mysite.com to https://www.mysite.com

    I've been trying to figure out how to do this with htaccess, but I can't find anything to forward both appropriately.

    Thanks for any help

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Riboflavin View Post
    Hi all, I am trying to forward an traffic that comes to http://mysite.com to http://www.mysite.com but I also need to forward https://mysite.com to https://www.mysite.com

    I've been trying to figure out how to do this with htaccess, but I can't find anything to forward both appropriately.

    Thanks for any help
    how do you decide what from http://mysite.com go to http://www.mysite.com and what to https://www.mysite.com?

    best regards

  • #3
    Regular Coder
    Join Date
    Sep 2004
    Location
    USA
    Posts
    314
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by oesxyl View Post
    how do you decide what from http://mysite.com go to http://www.mysite.com and what to https://www.mysite.com?

    best regards
    Here is my existing .htaccess (using magento ecommerce)

    Code:
    ############################################
    ## uncomment these lines for CGI mode
    ## make sure to specify the correct cgi php binary file name
    ## it might be /cgi-bin/php5-cgi
    
    #Action php5-cgi /cgi-bin/php-cgi
    #AddHandler php5-cgi .php
    
    ############################################
    ## this line is specific for 1and1 hosting
    
    #AddType x-mapp-php5 .php
    
    ############################################
    ## default index file
    
    DirectoryIndex splash.html index.php index.html index.htm
    
    <IfModule mod_php5.c>
    
    ############################################
    ## adjust memory limit
    
        php_value memory_limit 32M
    
    ############################################
    ## disable magic quotes for php request vars
    
        php_flag magic_quotes_gpc off
    
    ############################################
    ## enable php short tags for templates
    
        php_flag short_open_tag on
    
    </IfModule>
    
    <IfModule mod_ssl.c>
    
    ############################################
    ## make HTTPS env vars available for CGI mode
    
        SSLOptions StdEnvVars
    
    </IfModule>
    
    <IfModule mod_rewrite.c>
    
    ############################################
    ## enable rewrites
    
        Options +FollowSymLinks
        RewriteEngine on
    
    ############################################
    ## you can put here your magento root folder path relative to web root
    
        #RewriteBase /magento/
    
    ############################################
    ## always send 404 on missing files in these folders
    
        RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
    
    ############################################
    ## never rewrite for existing files, directories and links
    
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-l
    
    ############################################
    ## rewrite everything else to index.php
    
        RewriteRule .* index.php
    
    </IfModule>
    
    
    ############################################
    ## Prevent character encoding issues from server overrides
    ## If you still have problems, use the second line instead
    
    AddDefaultCharset Off
    #AddDefaultCharset UTF-8
    Order allow,deny
    Allow from all

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    I don't express my self to clear,
    how do you want to be? what url go where? you probably have an idea how , isn't it?

    best regards

  • #5
    Regular Coder
    Join Date
    Sep 2004
    Location
    USA
    Posts
    314
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Oh I see. Well I want it to redirect all URLs, I just want all pages to have www for seo purposes.

  • #6
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Riboflavin View Post
    Oh I see. Well I want it to redirect all URLs, I just want all pages to have www for seo purposes.
    ok, that means all url to http//:www....?

    best regards

  • #7
    Regular Coder
    Join Date
    Sep 2004
    Location
    USA
    Posts
    314
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by oesxyl View Post
    ok, that means all url to http//:www....?

    best regards
    Correct, but also all https://url to https://www.url

  • #8
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,027
    Thanks
    2
    Thanked 315 Times in 307 Posts
    This is off topic, but when posting a reply, it is not necessary to quote what was just posted in the previous post. That just makes for a longer read and makes it harder find what you wrote in your reply. Besides, we know that you are posting a reply related to the thread or you would not be posting (you don't get post points for how physically long you can make the thread.)

    Only include a quoted portion of a post when you specifically want to call attention to something about that specific part of a post.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #9
    Regular Coder
    Join Date
    Sep 2004
    Location
    USA
    Posts
    314
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Sorry, I'm just used to posting on bigger boards that move a lot faster, and if you don't quote posts get out of order rather quickly.

    Is it really that hard to determine what is a quote and what is my post?

  • #10
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    try this in .htaccess:
    Code:
    Redirect permanent http://mydomain.com/ http://www.mydomain.com
    and same for https.

    best regards

  • #11
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #12
    Regular Coder
    Join Date
    Sep 2004
    Location
    USA
    Posts
    314
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by oesxyl View Post
    try this in .htaccess:
    Code:
    Redirect permanent http://mydomain.com/ http://www.mydomain.com
    and same for https.

    best regards
    I tried this, but it doesn't seem to be redirecting at all

    Thanks, I've read through these before. I found that this code works for http

    Code:
    RewriteEngine On
    RewriteCond &#37;{HTTP_HOST} ^example\.com
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]
    However when I tried adding this code for https, It doesn't work:

    Code:
    RewriteEngine On
    RewriteCond %{HTTPS_HOST} ^example\.com
    RewriteRule (.*) https://www.example.com/$1 [R=301,L]
    Last edited by Riboflavin; 02-08-2008 at 09:30 PM.

  • #13
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,637
    Thanks
    6
    Thanked 1,004 Times in 977 Posts
    Quote Originally Posted by Riboflavin View Post
    Hi all, I am trying to forward an traffic that comes to http://mysite.com to http://www.mysite.com but I also need to forward https://mysite.com to https://www.mysite.com
    What you’re trying to do is one of the most useless things. Not only is this completely useless, also www. is deprecated so just forget it and rather redirect www. domains to their correct and actual non-www equivalent, will ya?
    Last edited by VIPStephan; 02-08-2008 at 10:08 PM.

  • #14
    Regular Coder
    Join Date
    Sep 2004
    Location
    USA
    Posts
    314
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by VIPStephan View Post
    What you’re trying to do is one of the most useless things. Not only is this completely useless, also www. is deprecated so just forget it and rather redirect www. domains to their correct and actual non-www equivalent, will ya?
    And who exactly is proclaiming it as depreciated? Some group of elitist web developers at no-www? Stop spamming my thread with useless links, will ya?

  • #15
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Riboflavin View Post
    I tried this, but it doesn't seem to be redirecting at all
    it must work if is not a typo somewhere, I use this few times.
    you could check by requesting one of your site page without www from your browser. If work few seconds after request the page address in browser must change.

    [QUOTE]
    Thanks, I've read through these before. I found that this code works for http

    Code:
    RewriteEngine On
    RewriteCond &#37;{HTTP_HOST} ^example\.com
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]
    However when I tried adding this code for https, It doesn't work:
    [QUOTE]
    try to find in what directory you must the documents for https,
    I guess is not the same with http,

    PS: IMO pr is not so important for seo, was just a way to evaluate your position

    Edit:

    And who exactly is proclaiming it as depreciated? Some group of elitist web developers at no-www? Stop spamming my thread with useless links, will ya?
    are few things here:
    - elite means progress
    - no-www make some sens, you could call me user-oesxyl and I call you user-riboflavin but user-vipstephan could say that is somehow redundant if we use coding forums ( http protocol, )
    - you have an option in google webtools with prefered domain so you can avoid redirection, is a better option

    PS: I have no opininion about no-www



    best regards
    Last edited by oesxyl; 02-09-2008 at 02:44 AM.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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