1

Trying to redirect my website from http to https, but its not working... website opens on both http and https.

This is the code section presently i used in my htaccess file, but this code not auto redirecting the website with https, and making the website open with both http and https. which is confusing so much.

    ------------------------------------------------

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
    RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
    RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
    RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
    RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule . /index.php [L]

    </IfModule>

    # END WordPress
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP:X-Forwarded-SSL} !on
    RewriteCond %{HTTP_HOST} ^www\.surffares\.com$
    RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
    RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
    RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule ^/?$ "https\:\/\/www\.surffares\.com\/" [R=301,L]

------------------------------------------------------------------------

but this code is not working ...

This is code godaddy suggested to use in htaccess for auto redirect, but this code only loading the front page, auto redirecting the front page only but no other page is opening, when i click any other page, it shows me a error not found.

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

--------------------------------------------------------------------

Godaddy Customer support told you need to pull inner pages in .htaccess.

How i can auto redirect my website from http to https and also pull all the inner pages of the website.

NOTE: my website is in php mvc laravel

1

2 Answers 2

3

I've quickly built a configuration to test this scenario. In Apache VirtualHost you need to make sure that htaccess-files are respected by apache with AllowOverride.

Here is the configuration within the VirtualHost:

    <VirtualHost *:80>

     ServerName test.com
     DocumentRoot /var/www

    <Directory "/var/www>
      Require all granted
      AllowOverride all
    </Directory

  </VirtualHost>

Then, in /var/www/.htaccess, define the following:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]

Hope that helps.

Jo

Sign up to request clarification or add additional context in comments.

3 Comments

<VirtualHost :80> ServerName test.com DocumentRoot /var/www <Directory "/var/www> Require all granted AllowOverride all </Directory </VirtualHost> RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.) https://%{HTTP_HOST}/$1 [R=301,L] need to write like this?
no, i edited my existing configuration, it worked, but the problem is now, when i am entering simple url without www or https, and trying to open some another page, for example, xyz.com/abc ... its redirecting me at home page... its happening with two pages only.... contact and payment page... i can't understand the reason
Search your configuration for redirects. The snippet I provided you won't cause these issues.
0
RewriteEngine On 
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www\.)?geoffreystevens\.com
RewriteRule ^(.*)$ https://www.geoffreystevens.com/$1 [R,L]

from madewithlove website it says This condition was not met.  How do I fix 
the code (or does it need to be fixed. This is for Linux in Godaddy. I bought 
an SSL and this is what they sent me for the htaccess. But now I see 2 
errors.
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.geoffreystevens.com/$1 [R,L]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.