As i have now https version of my website is it seo friendly to have "permanently moved" status 301, 200 and redirect the http url to https ?
I am using .htaccess to do this
RewriteCond %{HTTPS} !on
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Here is the example of the non http url test:
Go to https://httpstatus.io/ and test url http://sunnybeachtaxi.com/from-Sunny-Beach-to-Burgas-airport-options-Burgas-1-4-35/book/
returns 301, 200
Now another question is what canonical url should i use http or https ? I know google prefers https but still not sure. At the moment http urls are indexed and https are not becouse they appear to google as dublicates.
What is the best steps to achive this ? Should i first remove the http urls and then submit to google index the https ones?
Thanks
If you want to permanent redirect from HTTP to HTTPS then you should first of all purchase SSL certificate and activate it for your site. Nowadays google does not allow some site which is running without HTTPS. Just add SSL to your site and you do not need to submit it again into google webmaster just because of that if you have update time to time sitemap of your website. crawler automatically understand.
What is canonical URL's?
A canonical tag is a different way of telling search engines that a specific URL represents the master copy of a page. visit this SEO MOZ page for more information. https://moz.com/learn/seo/canonicalization
Thank you in advance
Related
My SSL is managed by cloudFlare but I prefer using htaccess method to control redirection of site to use HTTPS. I have a domain www.mysite.com and a sub domain demo.mysite.com. I want HTTPS on full website of www.mysite.com and on full website of demo.mysite.com as well except for just 1 page on my subdomain to prevent mixed content. That page can contain both HTTP and HTTPS links loaded in iFrame. Currently that page loads in HTTPS along with whole website but I want it to load in HTTP only and not HTTPS. The page is demo.mysite.com/surf.php which can be accessed by clicking an Ad at demo.mysite.com/ads.php.
I tried this in my htaccess file but the page surf.php still redirects to HTTPS.
# FORCE HTTPS
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} \/(surf.php)
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
# DISABLE HTTPS
RewriteCond %{HTTPS} on
RewriteCond %{SCRIPT_FILENAME} !\/(surf.php) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://%{HTTP_HOST}$1 [R=301,L]
I have disabled "Always use HTTPS" in my cloudFlare settings and my SSL is Flexible. Also, no page rules are set. I prefer htaccess method. Please help me and tell me what to do?
I have the following working on a domain in Cloudflare that has a flexible Cloudflare cert.
Instead of using .htaccess I have 2 Cloudflare page rules.
The first rule:
*.domain.com/page-to-ignore.htm
SSL: Off
Second rule:
http://*.domain.com/*
Always Use HTTPS
The order matters, and when testing on your own site, make sure you have cleared your browser cache.
Hope this helps!
If you are still facing trouble then you can also use a PHP code instead. Paste this code on your header file of the website or paste on each page where you want the website to be redirected to HTTPS or HTTP. Make sure to disable "Always use HTTPS" in cloudFlare and you can choose any SSL you want i.e, Flexible, Full or Full (strict).
PHP code for redirecting to HTTPS:
if($_SERVER['HTTP_HOST'] != 'localhost'){
if(!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on'){
if(!headers_sent()){
header("Status: 301 Moved Permanently");
header(sprintf('Location: https://%s%s',$_SERVER['HTTP_HOST'],$_SERVER['REQUEST_URI']));
exit();
}
}
}
PHP code for redirecting to HTTP:
if($_SERVER['HTTP_HOST'] != 'localhost'){
if(isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'on'){
if(!headers_sent()){
header("Status: 301 Moved Permanently");
header(sprintf('Location: http://%s%s',$_SERVER['HTTP_HOST'],$_SERVER['REQUEST_URI']));
exit();
}
}
}
This worked for me pretty well. Paste the code at the top of each page. If you are using session_start(); then place this code immediately after that. That's a good practice.
I am redesigning a website that is currently served over HTTPS via WPEngine. The new site will just be a static HTML landing page, which will be hosted on a totally new server over HTTP.
My concern is that users will get connection errors. Can I just use .htaccess to redirect HTTPS to HTTP to solve the issue?
May be this could help you, in htaccess
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
This will redirect https://www.test.com to http://www.test.com
For more http://www.hashbangcode.com/blog/using-htaccess-redirect-https-http
A client of mine wants to change their domain name, but wants to keep their Google ranking. To do this, they've pointed two domain names to the same IP, but we're having an issue where if you visit the site via the old domain, you get a security certificate warning and the page just loads with the old domain name.
What I'd like to do is detect when someone's coming to the site via the old domain and rewrite it to the new domain. For example, if they where to visit example.com/some-page.htm, it would rewrite to https://www.dummy.com/some-page.htm.
I found this code snippet somewhere that purports to do this, but it just brings the site down:
RewriteCond %{HTTP_HOST} !^example.com$ [NC]
RewriteRule ^(.*)$ https://www.dummy.com/$1 [R=301,L]
This is a WordPress site, so I'm using the normal WordPress rewrite rules, and I'm using the HTML5 Boiler Plate .htacess to enable http > https redriects, non-www > www redirects, and force HTTP Strict Transport Security, if any of that makes a difference.
You need to change condition to:
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^ https://www.dummy.com%{REQUEST_URI} [NE,R=301,L]
However keep in mind if you visit https://exampl.com and certificate is for dummy.com then SSL cert warning will still be there because SSL handshakes before mod_rewrite is invoked for redirecting to new site.
I want to redirect my wordpress login page to use HTTPS but do not want the rest of the site using it. I know how to redirect all the site via HTTP to HTTPS but not just a specific URL.
So I want http://example.com/wp-admin to go to https://example.com/wp-admin
This is what I currently have below and I have tried adding bits in but not got there.
Redirect / https://example.com/
You need to use mod_rewrite to enable https for a specific url.
Try the following in htaccess :
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^wp-admin/?$ https://%{HTTP_HOST}%{REQUEST_URI} [NC,L,R]
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]