.htaccess - redirected you too many times - html

htaccess gurus, I am having issues with connectivity with one of our websites that was working fine until last Friday (27th jan), www.astroflame.com. We currently use easyspace.com for domain name, hosting, emails etc. I have contacted the provider but they say everything is fine but when I do random tests on Edge, Chrome, Firefox (including private modes). Sometimes the site loads ok and sometimes this redirected you too many times error appears
www.astroflame.com redirected you too many times
to fix this issue, try clearing your cookies
ERR_TOO_MANY_REDIRECTS
Now the web service provider said to update our htaccess file to this:
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
But I am still seeing this redirected you too many times error. The site it self is just basic HTML, CSS, and a bit js.
Can anybody help ?

Related

Where do you write campaign code for redirects? .htaccess or index.html

I'm fairly new to .htaccess and proper re-directs. I recently bought domain.net and want to redirect to domain.com, but I want to track the traffic via Google Analytics campaign.
Would I put the UTM code in index.html? Should I do it somehow in .htaccess?
Sorry, I'm just a little new to this aspect.
I've researched how to track redirect traffic from domain.net to domain.com
You can put the following code into a .htaccess file.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.net$ [NC]
RewriteRule ^(.*)$ https://example.com/$1?utm_source=domain.net&utm_medium=redirect [NE,L,R=301]
Of course you have to replace the domains in this example.
If you search for "htaccess redirect google analytics" you will found some other solutions in the web too.

Local virtual hosts show Privacy Error on Chrome due to HSTS

I have created several virtual hosts for my development processes. They were working just fine till yesterday. But in my chrome app, today they stopped working. Chrome shows: NET::ERR_CERT_AUTHORITY_INVALID
All my vhosts end with .dev. I changed one .dev to .work and its again working. But I can not do this for all vhosts as there are too many of them. What do I do?
PS:
They are working fine in firefox.
The error remains same in chrome incognito mode.
I tried clearing cache and hard reload, deleted my history and cache, restarting chrome even windows multiple time, nothing works.
In one solution, I found an exception can be included in chrome://net-internals/#hsts. I tried deleting domain in there but somehow it still appears in Query Domain search.
Chrome have switched the .dev sub domain to HTTPS only.
They have done this by turning on HSTS for this top level domain, but by preloading this in the Chrome code rather than sending the HSTS header. This means it cannot be switched off in the chrome://net-internals/#hsts screen.
More info:
https://ma.ttias.be/chrome-force-dev-domains-https-via-preloaded-hsts/
So you’re only options are:
Update you’re vhosts to a different TLD (e.g. .test). And yes this might be painful because you have so many.
Move to HTTPS by creating a certificate and updating your URLs. A self signed certificate that you can create yourself will do, however note that HSTS not only blocks accessing the site over plaintext HTTP, but also prevents you clicking through certificate errors. So you’ll need to manually accept any certificate to your trust store before it can be used.
The chrome team have been pushing HTTPS more and more and certain features are now HTTPS-only so even dev envs will need it now. So maybe it’s finally time take the effort to make the switch.

ERR_TOO_MANY_REDIRECTS error after using Cloudflare

After I started using Cloudflare I started facing this error in my website(frequently in chrome and opera).
Some of the points I have found out after testing multiple times are:
So far I have faced this problem in Google Chrome, Chromium, and Opera. Chrome being the major one for my visitors.
The inner pages are working fine. For example example.com/about-us is working fine but the error occurs when we visit example.com .
I once thought this is because of too many links in my home page. So tried removing all the links on home page but the error continued.
If I type example.com/node instead of example.com it works fine(example.com/node being the default home page of drupal website). But users generally type example.com so it can't be the solution.
In cloudflare settings I have changed the SSL mode to "Full Strict" from "Flexible" as suggested in this answer. It's been more than 10 hours but it hasn't helped so far.
I am using Godaddy's linux hosting. It's a Drupal Website.
Any clue is appreciated. Thanks in advance.
Since you are using SSL the issue most likely is due to the fact that you have some redirects on your website ( .htaccess ) to the httpS version of the site . On top of that Cloudflare have features in their Crypto section that allow you to make redirects directly from there. Thus if you have set such rules both places, you will most likely get a redirect looop.
My advice would be for you to check the Crypto section of your CloudFlare account and make sure that
Automatic HTTPS Rewrites
and
HTTP Strict Transport Security
are disabled.
Then clear the Cloudflare cache and try accessing your website from a fresh browser.
This should do the trick, if not , you should provide us with your .htaccess content so that the case can be resolved.

Load Google Apps, while keeping my domain name

Basically, I am trying to redirect my own URL e.g. apps.mydomain.com to Google Apps. I would like to keep my domain name in the URL.
I tried using iframe, but it does not load Google in an iframe. It does load other websites. I also tried using htaccess and the [P] flag, but it says index.html not found.
mod_rewrite is enabled on my server.
Any help would be greatly appreciated.
Edit
The [L] redirect seems to work.
You won't be able to this. Google have enabled X-Frame-Options: Deny which prevents this scenario for security reasons.
Further reading: https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options

How do I stop search engines indexing a maintenance page

I need to setup a maintenance page for a website I'm running, e.g. for display when I'm performing site maintenance (scheduled downtime) or if something really breaks and I need to put up a holding page.
Is there anything special I need to do to ensure that search engine crawlers don't index it and think that it's my site. Or should I do a 404, add a temporary robots.txt file or something? I basically don't want them to index it as my site, but I also don't want them to think my site is dead and not come back.
Edit: Here's what I did in Apache: ErrorDocument 503 /.server-maintenance.html RewriteEngine On RewriteRule !^.server-maintenance.html /server-maintenance Redirect 503 /server-maintenancestrong text
You should send a 503 Service Unavailable HTTP status code, and not a 404. Use this in conjunction with a Retry-After header to tell the robots when to come back.
You may use a robots.txt
http://www.robotstxt.org/
Also, google has a validator in their webmasters tools.
https://www.google.com/webmasters/tools/
Returning 503 Service Unavailable tells Google bots to come back later. There's a Google support page describing the HTTP error codes and how they are interpreted by them.
You can also use Retry-After response header to suggest the minimum time after which your site is re-checked for availability.
Another approach would be to not link the maintenance page from any other page on your website (or any other website).