1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

.htaccess file help

Discussion in 'Site & Server Administration' started by CarpCharacin, Dec 1, 2016.

  1. #1
    So I need to redirect all non www and non https traffic to https www /forums. I have tried several .htaccess codes and none of them have worked. What is one that will work?
     
    CarpCharacin, Dec 1, 2016 IP
  2. weblinsolutions

    weblinsolutions Active Member

    Messages:
    29
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    68
    #2
    Try the following code.

    RewriteEngine on
    RewriteBase /

    RewriteCond %{REQUEST_URI} !^/forums/

    # Rewrites all URLS [Replace "domain" with the actual domain, without the TLD (.com, .net, .biz, etc)]
    RewriteCond %{HTTP_HOST} ^(www\.)?domain\.

    # Rewrite all those to insert /folder
    RewriteRule ^(.*)$ /forums/$1 [L]

    First check if this works and then we can modify the final request to be https www
     
    weblinsolutions, Dec 1, 2016 IP
  3. CarpCharacin

    CarpCharacin Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    90
    #3
    It works, but it does not redirect all URLs to be HTTPS. It redirects the main site to be https www, but it does not redirect the http to https if I take out the s in https or the www.
     
    CarpCharacin, Dec 1, 2016 IP
  4. weblinsolutions

    weblinsolutions Active Member

    Messages:
    29
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    68
    #4
    You can use an additional redirect to do that but I don't like the idea of using two redirects as it adds to the load time. I'll ask my server specialist if he can suggest a proper redirect method for this. Will let you know soon.
     
    weblinsolutions, Dec 1, 2016 IP
  5. CarpCharacin

    CarpCharacin Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    90
    #5
    The redirect you have me didn't work. I was actually using an old redirect I generated in the hosting cpanel as a temporary one. I need to get it fixed.
     
    CarpCharacin, Dec 1, 2016 IP
  6. CarpCharacin

    CarpCharacin Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    90
    #6
    I still haven't found a redirect.
     
    CarpCharacin, Dec 2, 2016 IP
  7. CarpCharacin

    CarpCharacin Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    90
    #7
    I still need a redirect.
     
    CarpCharacin, Dec 6, 2016 IP
  8. UnderHost_MSA

    UnderHost_MSA Notable Member

    Messages:
    1,194
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    200
    #8
    Try this:

    
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^$
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteCond %{HTTPS}s ^on(s)|
    RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    RewriteCond %{HTTPS} off
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
    
    Code (markup):
     
    UnderHost_MSA, Dec 8, 2016 IP
  9. CarpCharacin

    CarpCharacin Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    90
    #9
    It didn't work. I need to redirect the main domain to /forum.
     
    CarpCharacin, Dec 13, 2016 IP
  10. CarpCharacin

    CarpCharacin Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    90
    #10
    Will that redirect the main domain to /forum? I don't think so. Also will that redirect every URL to HTTPS AND www?
     
    CarpCharacin, Dec 13, 2016 IP
  11. CarpCharacin

    CarpCharacin Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    90
    #11
    I want to change all http to https, but I also want to change all non www to www. and redirect to /forums.
     
    CarpCharacin, Dec 13, 2016 IP
  12. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,151
    Likes Received:
    1,656
    Best Answers:
    29
    Trophy Points:
    475
    #12
    I played with re-directs in my cPanel and this is the solution it gave me:
    
    RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com$
    RewriteRule ^/?$ "https\:\/\/www\.yourdomain\.com\/forums\/" [R=301,L]
    
    Code (markup):
     
    qwikad.com, Dec 13, 2016 IP
  13. CarpCharacin

    CarpCharacin Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    90
    #13
    It dosen't work. It just dosen't do anything.
     
    CarpCharacin, Dec 14, 2016 IP
  14. aboadamdeme611

    aboadamdeme611 Greenhorn

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #14
    The beginning it is necessary to explain the possible errors for the entry of visitors to the pages of the site, namely:
    400 - Bad Request .. means the wrong application of the page
    401 - Authorization Required ... means that he is not licensed for the visitor viewing the page
    403 - Forbidden .. means it is forbidden for visitors from entering the page
    404 - File not found ... it means that the page that the visitor have requested does not exist
    500 - Internal Server Error means that there is an error in the site's server
    503 - Service Unavailable ... means that the service is not available
    These are the common mistakes and there are more other ..
    To make the error page write in the htaccess file. The following code:



    ErrorDocument [error number] [path]
     
    aboadamdeme611, Dec 17, 2016 IP
  15. CarpCharacin

    CarpCharacin Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    90
    #15
    I explained what I needed to do in the first post.
     
    CarpCharacin, Dec 17, 2016 IP
  16. CarpCharacin

    CarpCharacin Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    90
    #16
    I still need a .htaccess code.
     
    CarpCharacin, Dec 18, 2016 IP
  17. CarpCharacin

    CarpCharacin Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    90
    #17
    So I want to force www and HTTPS on all URLS and I want to redirect the mai domain to /forum. How can I do that using .htaccess?
     
    CarpCharacin, Dec 29, 2016 IP