After change from HTTP to HTTPs, landing page works, rest not - .htaccess

I'm using OsClass for my website. When I've activated ssl certificate, my webside was down. I've updated my .htacess with code which I've got from my hosting
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
so finally I can see my web, landing page, oc-admin... but rest of the page is down
Not Found
The requested URL /item/new was not found on this server.
Hope it is just something simple. Can you please help me with that ?

Related

website keeps redirecting to HTTP

i have just installed my SSL wich i have bought on transip.nl
When i take a look at the website which i have installed for it looks like its not going well.
i have checked : https://www.sslshopper.com/ssl-checker.html#hostname=sloffenenpantoffels.nl
Looks fine but its not. there is no safe logo and he is still telling its an unscure connection.
When i check the URL its HTTP and not HTTPS.
Webshops is build in a magento multistore.
I have made own domain and selected his own IP for the SSL. I pointed the root folder to the folder from the main domain of the multistore.
In my htaccess file there is a rule:
RewriteCond %{HTTP_HOST} ^(.*)sloffenenpantoffels.nl
RewriteRule ^ - [E=MAGE_RUN_CODE:ditwiljehebben]
I hope that anyone can help me out here.
To force SSL just use the following:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

.htaccess redirect but show different URL

I want my site to act like this. If user inputs site.cz it should be redirected to site.eu/?lang=cs but the user should still see site.cz. Right now I have the following htaccess file:
RewriteCond %{HTTP_HOST} site\.cz [NC]
RewriteCond %{REQUEST_URI} ^/$
Rewriterule ^(.*)$ http://site.eu/?lang=cs [L,R=301]
which works great and redirects only .cz request (dont do anything with .eu requests) but it displays .eu/?lang=cs in final. Problem is that I dont only want to display site.cz all the time but also links like site.eu/folder1/file1/?lang=cs should be redirected to site.cz/folder1/file1/
Any ideas how to accomplish this?
Thanks in forward
Are you using XAMPP or a web host? Upon testing, URL rewriting isn't working in XAMPP.. Anyway, you can try to check this, just make sure that your two sites are hosted by the same web hosting account:
RewriteCond %{HTTP_HOST} site\.cz [NC]
RewriteRule ^(.*)$ http://site.eu/$1?lang=cs [P,L]
But it looks like your sites aren't hosted by the same hosting account as what you've said:
when I use [P] flag I get an error "Following URL was not found on this server" – horin

Forcing domain to load over HTTPS

I've recently installed on my website a CloudFlare SSL Certificate.
However, when I am trying to force my website over HTTPS, I fail.
I firstly attempted to create a redirect from HTTP to HTTPS from my web host control panel (Hostinger), but apparently, you cannot create a redirect for the same website.
After this, I went to the .htaccess file and edited it, adding the following codes:
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^.*$ https://www.domain.com%{REQUEST_URI} [R,L]
Error: The broswer does not redirects me to load the domain over HTTPS.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]
Error: In Google Chrome I get the following error screen:
This webpage has a redirect loop
ERR_TOO_MANY_REDIRECTS
In Opera, the web page does not load.
I tried to delete my Chrome's cache, but it still didn't work.
Any tips?
You can utilise CloudFlare's page rules. Login to your account, head over to page rules. Click "Create Page Rule".
type in your domain name in the following format: http://example.com/* and add the setting
Always use HTTPS
Then press save and wait 30 seconds.

Redirect all but one page to http from https

For reasons of SEO, I would like to redirect all but one of the pages of my website from https to http. Currently, if you visit the https:// version you are presented with my website and the aforementioned prefix is in the address bar. If you visit the http:// version the https:// prefix is absent. Apparently, as a result, Google treats my site as if it were two identical sites. Not good for SEO.
St.Woland's answer here was very helpful in redirecting almost all the pages of my website from https to http. In fact, it worked like a dream until I tried visiting the one page that needed to have the secure connection.
Before trying his fix, were you to visit the secure basket page the whole page was marked as secure. However, with the recommended .htaccess fix in place, all images and css were flagged as insecure and Chrome refused to load them; the page looked a mess.
It seemed like an article on Best Host Ratings had the solution: add further .htaccess files to the images and css folders and all would be well.
Sadly, this then meant that those pages without the https:// prefix did not load the css or the images.
Please see below the code I put in. Firstly, the .htaccess to redirect all but the basket page from https to http:
RewriteEngine On
RewriteBase /
# Turn SSL on for basket
RewriteCond %{HTTPS} off
RewriteCond %{SCRIPT_FILENAME} \/basket\.php [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
# Turn SSL off everything but basket
RewriteCond %{HTTPS} on
RewriteCond %{SCRIPT_FILENAME} !\/basket\.php [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
Secondly, the .htaccess I placed in the images directory:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} images
RewriteRule ^(.*)$ https://www.domain.com/images/$1 [R,L]
An obvious solution to this situation might be to just redirect the whole site across to the https version. But, placed at the base of all pages except the basket page is script from Google AdWords that places relevant ads across the internet after users have visited my site. This script is flagged as insecure.
Any help with this issue would be most appreciated.
With kind regards,
Mark

https to http redirection when ssl is not installed

We have a site which was https enabled. After a site revamp we have removed the certificate and https://www.foo.com is not http://www.foo.com.
There are many links in other sites, which link to th old https site, which we have no control. Is there something we can do in out side to redirect these links to home page atleast?
Will url rewriting work in this case?
There were some broken link which we fixed with a custom 404 page and tracking the links.
Does this belong to serverfault?
You're pretty much out of luck - you can do URL rewriting as #Josh says, but before the browser even gets that far, most of them will give the user a big warning message telling them the SSL certificate isn't valid, which will put off most of the visitors.
I'd recommend buying an SSL certificate - they're not so expensive - then doing the rewrite.
using mod_rewrite
# forces everything to non-secure if secure (http)
RewriteCond %{SERVER_PORT} =443
RewriteRule ^(.*)$ http://%{SERVER_NAME}/$1 [R,L]
Josh
The solution for IIS may be ISAPI_Rewrite 3. Here's the .htaccess:
RewriteBase /
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]

Resources