Having problem redirecting HTTP to HTTPS inner pages with .htaccess

Sizus

BANNED
Joined
Jul 4, 2015
Messages
376
Reaction score
331
I hope someone skilled in this can help me.

I use code below which I was told it should redirect all pages (homepage + inner pages) from http to https.

However it only redirects home page. My site is static html site with few pages only. Not Wordpress because I don't need it.
I don't want to switch to Wordpress because my site has great SERP position and I don't want to change its structure.

This is the code I'm using and it only works for homepage to redirect it to https.

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

Does anyone has some solution which can work for me, please?

I read tons of pages which I was googling and can't find working solution anywhere.

Regards,
Sizus
 
Try this and see where ot gets you: https://kinsta.com/knowledgebase/redirect-http-to-https/#settings_saved

Good luck!

I have tried this code already, it's posted in my first post here, and it doesn't work for me for inner pages. All other methods explained on that website are for Wordpress.


try this:
Code:
    RewriteEngine on
    RewriteCond %{SERVER_NAME} = yourdomain.tld [OR]
    RewriteCond %{SERVER_NAME} = www.yourdomain.tld
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

Not working. Do I need to change "SERVER_NAME", if yes, where I can find it? Is that my cPanel's username?

And is this code for whole website (with inner pages) or just for homepage? I need for inner pages and homepage, one code for all.

Thanks
 
you can put it in the .conf file of your http server, or you can put it into .htaccess.
no you don't need to change SERVER_NAME, but you need to change "yourdomain.tld" to your actual domain.
it works for the whole domain including inner pages.
 
you can put it in the .conf file of your http server, or you can put it into .htaccess.
no you don't need to change SERVER_NAME, but you need to change "yourdomain.tld" to your actual domain.
it works for the whole domain including inner pages.

Well I put it inside my htaccess, only changed yourdomain.tld to my one, nd after that I get Internal Server Error. Site does not load at all.
 
Well I put it inside my htaccess, only changed yourdomain.tld to my one, nd after that I get Internal Server Error. Site does not load at all.

Try renaming your .htaccess file and see if the site gets back online.

Is this pure html or another CMS?
 
Try renaming your .htaccess file and see if the site gets back online.

Is this pure html or another CMS?

Pure html.

Rename into what ? It’s named “.htaccess”

I’m not that stupid xD
 
Rename into what ? It’s named “.htaccess”
If you rename it to anything else, it will disable the directives entirely, and the results should let you debug further.

Pure html.
Do you have htaccess files in the subfolders as well? If so, what are the contents?
 
If you rename it to anything else, it will disable the directives entirely, and the results should let you debug further.


Do you have htaccess files in the subfolders as well? If so, what are the contents?

Only subfolder is “images”

And file is named “.htaccess” , Inside there is now code from my first post, which only can redirect home page, not other pages.
Other pages are not in subfolders, but named like “about-us.html” etc.

Weird thing is that the same code from my 1st post here can work for all pages on my other hosting accounts of other providers, for my other sites. There, this code can redirect home page and inner pages. It works good, but on this hosting it does’t. I’m using shared hosting.

And I contacted support but still no reply.

I wonder if there is some other code which can work for me, or I will need to transfer my site to another hosting company.
 
are you sure your host got php setup to use mod rewrite ask the host ?

maybe mod rewriite module not activated/installed.
 
are you sure your host got php setup to use mod rewrite ask the host ?

maybe mod rewriite module not activated/installed.

Hey,

I’ve got reply from support team. They needed to change something in server settings.
Normaly this code from 1st email should work.

Thanks for trying to help to you and everyone who posted.

Kind regards,
Sizus
 
Back
Top