My homepage wont go through HTTPS port - apache

So my domain is [1] and as you can see whenever you go on that link it will get HTTP (without padlock) but if you go to any other link it will be HTTPS. Only my homepage goes through HTTP.
Important things to mention is that I use Apache.
Every my attempt to edit .htaccess file ends up by website stoping to work. My whole website is hosted on AWS and that is where I derived my SSL certificate.
I want to make that homepage load in HTTPS as well.
How should I do that?
Here is my app folder and place where I created my .htaccess file.
[1]:

Adding this to your .htaccess should do it:
RewriteEngine on
RewriteCond %{HTTPS} =off
RewriteRule ^$ https://www.urtina.com/ [L,R=301]
If it breaks Apache, check the error log. It is for the homepage only as requested.

Related

Using htaccess, Redirect http or https domain, and any subpage to particular page on another server

Background:
We have DNS pointing to new server.
Apache Server has a directory called example
Example directory has an htaccess file for redirecting, code below
Issue is : We need this to redirect any variation of the url ie: http://example.com, https://example.com, http://example.com/filename.html, https://example.com/directory/filename.html, etc.. to a specific page on another server.
So far, we have the code below, it works correctly for https, but not http.
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ https://differenturl/login/login.html [R=301,L]
I feel like there is a simple answer but can't seem to find it!
**Edit: for clarification -by not working, I mean that I am not redirected to https://differenturl/ etc... using http. It only works for https. http routes me to the home page of the server that this all sits on. And that server has a different domain name than anything above.
If it's "not working" for HTTP then either:
The <VirtualHost> container for port 80 (ie. HTTP) is not configured at all in the server config.
Or,
The vHost:80 container is pointing to a different area of the filesystem, so the .htaccess file is not processed.
Or,
The vHost:80 container does not permit .htaccess overrides so the .htaccess file is ignored. You either need to configure .htaccess overrides by setting AllowOverride All in the appropriate <Directory> container in the vHost:80 container. Or simply redirect everything to HTTPS in the vHost:80 container (eg. Redirect / https://example.com/) and then allow the .htaccess file to redirect from HTTPS. (That's potentially 2 redirects, but that should not be an issue.)
Or just do the redirect (to the other server) in the server config and not use .htaccess at all.

http to https infinite redirect

I am using ZenCart and trying to ensure HTTPS onto my website. I have used the following in my .htaccess
RewriteCond %{HTTPS} off
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
But I still get an infinite redirect error
In ZenCart and the configure files I have tried making both
HTTP_SERVER
HTTPS_SERVER
The HTTPS but it has no affect
I'm unsure how to force people when they enter my website at http://example.com to go to https://example.com as any .htaccess code I use causes an infinite redirect
There are no other redirects set-up and this is the only piece of code in my .htaccess file
you can avoid using .htaccess redirects.
in your zen-cart configure.php files, ensure that the HTTP_SERVER and HTTPS_SERVER are both set to: https://yoursite.com. you can then add the 3 files contained in this PR and it should work fine:
https://github.com/zencart/zencart/pull/1525/files

How to redirect to subdomain but then allow normal use of site

So I have my site, www.domain.com.
For a week or so I want to direct all traffic going direct to the site to subdomain.domain.com, a little promo page about an upcoming feature. I want visitors to then be able to continue to the site as normal though after they've read it, so a continue to www.domain.com/index.php link.
How can I do that with in the htaccess file? Everything I've tried so far messes up when clicking the continue link.
Thanks
with .htaccess you could use a 302 temporary redirect, but it would be for a whole sub folder as far as I know.
Another way would be to redirect with JS/server site language to the subdomain, create a cookie, then redirect back to www.domain.com/index.php .
the 302 redirect is explained here: How do I redirect my site using a .htaccess file?
You would need to have a .htaccess for the root folder point to your subdomain
Note that this is only possible if you enable mod_proxy in the Apache config of domain.com otherwise URL will change after redirect.
Enable mod_proxy, mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^index\.php$ http://subdomain.domain.com/ [L,NC,P]

https rewrite or redirect in a shared hosting environment

My web host is hostgator.com with Apache, cPanel, etc.
A spammer somewhere has set links to my site somewhere, using https in the URL. I don't have an SSL certificate and would expect these links to resolve to the error 404 page.
However the links cause Firefox to say my domains are attack sites, due to their hookup with Google safe browsing.
Hostgator support is slow and clueless. Links are in the following format.
https://mydomainname.com/
https://mydomainname.com/digital-photography-forum-uk/
https://mydomainname.com/fastibl/
https://mydomainname.com/search-engine-marketing/
https://mydomainname.com/search-engine-optimisation/
https://mydomainname.com/website-programming-discussion/
I've edited .htaccess a dozen times, using online examples of redirecting https to http and nothing (yet) works.
Just try these configuration directives in your .htaccess file:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://mydomainname.com/$1 [R=301,L]
But please considered the [R=301] flag with this link: https://stackoverflow.com/a/15999177/2007055
Or try to use a robots.txt file if it can block or remove the pages in HTTPS on search engines. And if any of those solutions did not work, then you've better purchase an SSL certificate to solve your problem.

apache configure site maintainance page

I am trying to configure in apache httpd.conf for the below scenario. Can anyone please advise how to do it.
When the apache instance is up and some one tries to hit below url
http://mydomain.com/xxx
It should display content exists in sitemaintenance.html without changing url context path.
Assume sitemaintenance.html resides in /usr/local/apache/my-apache-instance/htdocs/sitemaintenance.html
Here xxx is a subdomain which is hosted separately from main domain (mydomain.com).
-KS
Try placing this into httpd.conf or .htaccess for your sub-domain:
RewriteEngine on
RewriteCond /usr/local/apache/my-apache-instance/htdocs/sitemaintenance.html -f
RewriteRule ^.*$ /sitemaintenance.html [PT,L]
The condition in RewriteCond enables rewrite only if that file exists, so you can dynamically add or delete it, without re-starting Apache or changing .htaccess.