Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Https redirection help !!!
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Https redirection help !!!

kamalkamal Member

I have been trying to redirect my site to https and also from non www to www but It works on the root domain but the .htaccess I place on the website's root directory doesn't effect the sub directory hence.. the sub directory aren't redirected to https or from non www to www

Please kindly help

Comments

  • kamalkamal Member

    I am using Godady cPanel Hosting.
    And looks like no inheritance to the sub directories

  • trvztrvz Member

    You've got your .htaccess wrong.

  • rokokrokok Member

    pastebin your .htaccess so people can help :)

  • ShivamShivam Member

    Hey man, use this.

    SSL Rewrite

    RewriteEngine On

    RewriteCond %{HTTP:X-Forwarded-Proto} =http

    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

  • kamalkamal Member

    my .htaccess is blank.. I haven;t setup any redirection rules for now...

  • kamalkamal Member

    @Shivam this doesn't work

    RewriteEngine On
    RewriteCond %{HTTP:X-Forwarded-Proto} =http
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

  • adxnadxn Member, Host Rep

    Simple

    RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.yoursite.tld/$1 [R,L]

  • kamalkamal Member

    @adxn it works for the root directory but doesn't work for yoursite.tld/subdomain Any other clues ?

  • ShivamShivam Member

    Works for me mate.

  • adxnadxn Member, Host Rep
    edited May 2015

    kamal said: @adxn it works for the root directory but doesn't work for yoursite.tld/subdomain Any other clues ?

    While issuing your SSL make sure to use the following format www.yoursite.tld as domain name

    and for subdomain u must have a wildcard SSL

  • adxnadxn Member, Host Rep

    adxn said: While issuing your SSL make sure to use the following format www.yoursite.tld as domain name

    and for subdomain u must have a wildcard SSL

    for sub directory add that .htaccess there too

  • kamalkamal Member

    I was sorry I was referring to sub directory and not a sub domain, my sincere apologies.

  • CloudconeCloudcone Member, Patron Provider

    Place the same .htaccess on your sub directory as well

  • kamalkamal Member

    When I add the .htaccess in the sub directory should I place it like following

    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://www.yoursite.tld/$1 [R,L]
    

    or

    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://www.yoursite.tld/subdirectory$1 [R,L]
    
  • BharatBBharatB Member, Patron Provider

    RewriteEngine on

    RewriteCond %{SERVER_PORT} 80

    RewriteRule ^(.*)$ https://readydedi.com/$1 [R,L]

  • kamalkamal Member

    thank you BharatB will it also work for the sub domain.. the .htaccess on the root domain doesn't get inherited by the subdirectories

  • jarjar Patron Provider, Top Host, Veteran
    edited May 2015

    @kamal said:
    thank you BharatB will it also work for the sub domain.. the .htaccess on the root domain doesn't get inherited by the subdirectories

    .htaccess files are read recursively. If it does not impact a sub directory this means that you have overriding configuration for that sub directory in a .htaccess file or virtual host. Also possible your application triggers a redirect in its code.

  • AICAIC Member

    @Jar said:
    .htaccess files are read recursively. If it does not impact a sub directory this means that you have overriding configuration for that sub directory in a .htaccess file or virtual host. Also possible your application triggers a redirect in its code.

    I do agree @jar , The above .htaccess will work for subdomains as if your ssl type is wildcard ssl. If not you will get an error for subdomains.

    If you are using .htaccess specifically in subdirectories you have to add the code to .htaccess of subdirectories, if not there is no need to add .htaccess file in the subdirectories. Check your code and find where the absalute path is defined for the http.

Sign In or Register to comment.