Jump to content

.htaccess question, http to https?


MCF

Recommended Posts

Hello,

When I had a piece of coding done for me, the .htaccess looked like this:

RewriteEngine On
RewriteRule ^([^/]*)\.html$ index.php?pagina=$1 [L]

RewriteCond %{HTTP_HOST} ^website.com [NC]
RewriteRule ^(.*)$ http://www.website.com/$1 [L,R=301,NC]

But this was in the http era, now my host has provided me with a SSL and I want to use https.
Can I just go ahead and replace the 'http' parts to 'https' or won't it work/break my site/cause security issues?

I asked the guy who made it for me but he couldn't remember what to do with it as I had this programmed by him over 6 years ago.

Basically the coding is some sort of semi cms system as an alternative to iframes in .html pages, the .php pages are converted to .html.
Supposedly better for the search engines, and I can modify my own site to my wishes without any security to worry about it as it doesn't use any database or anything.

Thanks!

Link to comment
Share on other sites

You might be able to do just that, yes. "Might" because we have no idea what your application is.

As long as it isn't trying to link to itself as "http://www.website.com/page.html", and is just using server-relative paths like "/page.html", then everything should continue working. If it is using "http://" links then those have to be fixed manually.

You should also support redirecting from http to https, though. All you need to do is add another condition to the redirect already there to say that it should happen if the URL was http or website.com. Which I would write differently:

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !www.website.com
RewriteRule ^ https://www.website.com%{REQUEST_URI} [L,R=301]

 

Link to comment
Share on other sites

Hi thanks for replying!

Basically it's just a set of .php files in three folders called 'content' 'html' and 'seo'. And in images folder, with in the root of all a .index.php and style.css.

What I wanted was to build a .html website but I didn't want to have to edit every page when changing something e.g. in the footer or menu. In the past I used iframes, but apparently search engines don't support it much and it may cause issues with responsiveness.
So, now I have .php files which 'convert' to .html extension. Basically I needed the 'include file' thing as a replacement for the iframe, so that's why it had to be .php files instead of .html files. 
Hope that explains it a bit more. Like I said, there's no database or anything.

Yes, in my editor it looks like the paths are all 'relative', I don't have any 'full' links that include the domain name AND the .html file path. If that's what you meant.

Now, I have some things set in the DirectAdmin of my host:

Force redirect: No redirection
Redirect HTTP to HTTPS: YES
Private_html setup (SSL): Use a symbolic link from private_html to public_html - allows for same data in http and https: YES

Just listed that data to be sure it won't interfere with your provided .htaccess code?

Hey, thanks!

Link to comment
Share on other sites

12 minutes ago, MCF said:

Yes, in my editor it looks like the paths are all 'relative', I don't have any 'full' links that include the domain name AND the .html file path. If that's what you meant.

It is.

 

12 minutes ago, MCF said:

Just listed that data to be sure it won't interfere with your provided .htaccess code?

Try going to http://www.website.com without my changes and make sure it redirects. If so then you can disregard.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.