(New to web development)
I'm using nginx for my nodejs website on a Digital Ocean instance.
I'm using passport.jsfor facebook login on http://www.example.org/login. My callback URL is http://www.example.org/auth/facebook/callback.
The session works if I access the website using http://www.... but it gets lost if I switch from http://www to http://
I've already tried creating a redirect in /etc/nginx/sites-available/default using:
server_name example.org
rewrite ^/(.*)$ http://www.example.org/$1 permanent;
but this isn't working. What am I doing wrong?
Can anybody help me with setting the session for both www and non-www versions of my domain in nodejs, or correctly writing the redirect?
Related
I have a problem with redirecting my website to new domain. I my old domain is https://elysian-store.ir
I decided to buy the .com version in order to have google advertisment for my site (.ir is banned!!! and thought the net was free of politics)
Anyways, here is my situation:
Old website: https://elysian-store.ir
New domain: https://elysian-store.com
I want to redirect all of content old website, to the new with considration of all verieties like :
www.elysian-store.ir or .com
http versions to https versions.
I have added all versions to google web console and tried to implement redirect codes to htaccess of my website.
I use latest version of wordpress.
If someone could put me in the right direction for 301 redirect it would be great.
I have access to website cpanel too.
Do you need the directories to be appended to the redirect? If so then this should work:
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ http://elysian-store.com/$1 [R=301,L]
I am experiencing a weird problem on enabling ssl on various opencart installations of 2.1.0.2 version.
I have a VPS that has SSL via the new cpanel to all acounts available.
I have already enabled ssl and https on many opencart 1.5 versions, wordpress and even old joomla accounts.
However when i try to enable https on any opencart 2.1.0.2 version via the following procedure i get a bizarre redirection to a suspended account of my vps.
The procedure i follow for ssl in opencart 2.1.0.2 is:
I edit the config.php files both at public_html and admin to
// HTTPS
define('HTTPS_SERVER', 'https://example.com/admin/');
define('HTTPS_CATALOG', 'https://example.com/');
I enable ssl via the backend server settings in opencart
and i add in my .htacces file
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
right after
RewriteEngine On
I even tried to force https to all links in config files as:
// HTTP
define('HTTP_SERVER', 'https://example.com/admin/');
define('HTTP_CATALOG', 'https://example.com/');
// HTTPS
define('HTTPS_SERVER', 'https://example.com/admin/');
define('HTTPS_CATALOG', 'https://example.com/');
with no luck.
Any ideas?
thank you
Before you add any configuration changes, visit your site:
https://example.com/
If you still get the weird, unexpected page - contact your host, as there's no change in OpenCart you can do to fix a server misconfiguration.
With that said, how did you "enable" SSL? Via Let's Encrypt or a purchased SSL? If you only added the https to your config files, you do not have any SSL enabled. Your host may 'offer' it, but it may not exist by default.
If your host offers it via your cPanel, install a free SSL via the Let's Encrypt cPanel plugin. It should be done automatically and only take a few seconds to complete and you would receive a success message once it's been installed and activated to your site.
I've got a strange problem with https not redirecting to http. I need https://indudlgeinbrighton.co.uk to redirect to http://indulgeinbrighton.co.uk It's on a shared server and I'm getting a strange cross over with the https. When https is put in, it's loading information for a completely different website hosted on the server.
https://indulgeinbrighton.co.uk is the URL affected. I don't normally share the URLs I'm working on, but in the case I think it might be helpful to see what's going on. Where it's showing data for a website called Churchill, obviously this is a bit of a problem. I've tried putting in all the solutions provided on this page How do you redirect HTTPS to HTTP? into the root .htaccess but it's not working. The htaccess is working fine, because when I switched it to load the other way from http to https it worked fine.
I can only assume it's reading the htaccess file from the other site when it's looking at the https version. As I know which site it is, that's easy enough to locate, but what could I put in that htaccess file to redirect this particular url query without affecting https redirects on the other site?
Thank you.
try this in your .htaccess
RewriteEngine On
RewriteCond %{SERVER_PORT} 443
RewriteRule ^(.*)$ http://indulgeinbrighton.co.uk/$1 [R,L]
this is for security measure
The page at 'https://indulgeinbrighton.co.uk/' was loaded over HTTPS,
but requested an insecure script
'http://churchillbrighton.com/wp-content/themes/brighton-hotels/js/avia.js?ver=3'.
This request has been blocked; the content must be served over HTTPS.
you can try to do this in PHP
$protocol = isset($_SERVER["HTTPS"]) ? 'https' : 'http';
or include always external files in https
I have five hosted domains with a multi-domain SSL certificate. I cannot write an .htaccess condition that captures both http and https conditions for CNAME www.altdomain.com (a secondary domain). When a user types "https://altdomain.com" in the browser location bar, it shows "connection untrusted" and the URL remains as is. Typing the same with http correctly redirects to https://www.altdomain.com and when the https is omitted, "altdomain.com" is correctly redirected as well.
I am using joomla with a configuration that hides a subdirectory from the URL. The doc root .htaccess file contains this in the custom redirect section:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^altdomain\.com
RewriteRule ^(.*)$ https://www.altdomain.com$1 [R=301,L]
Activating a joomla SSL plugin while omitting custom redirect rules in .htaccess also works, but "https://" with "altdomain.com" fails to redirect in all cases. Perhaps I should have omitted www from the CNAME but there would be a redirect issue there as well if anyone types www in the URL, and I can't change the CNAME without purchasing a new SSL certificate. If there is no .htaccess solution to this problem as I suspect, please explain why.
The standard redirect between www and non-www URLs works only on the primary domain or for http connections. For secure / https connections on secondary domains, there must be an exact CNAME match on the SSL certificate - redirection to a host name that is not listed as a CNAME on the certificate will not work even if the domain name is the same.
If I want https connections to redirect from altdomain.com to www.altdomain.com and vice-versa on a multi-domain SSL certificate, I have to include both CNAMES in the certificate. A five-domain SSL certificate is therefore limited to three domains.
Redirecting to different server but same domain.
I have 2 servers on different hosts. One has domain.com and the other domain.org. domain.org has more resources. Now i want to create a sub domain on the first one (sub.domain.com) and redirect to (sub.domain.org) whiles maintaining the .com in the urls.
Thanks.
It depends on what's your hosting running on (Apache, nginx etc...).
In nginx you can use proxy_pass to redirect request to another host while still preserving url:
location / {
proxy_pass http://domain.org:80;
proxy_set_header X-Real-IP $remote_addr;
}
Take look at nginx docs for more info: http://wiki.nginx.org/HttpProxyModule
Or this discussion can be helpful: http://www.webmasterworld.com/apache/4464836.htm
It may be possible to also do this by manipulating DNS records so sub.domain.com is resolved to host where subd.domain.org is running (but you need to handle HTTP Host header in webserver)
There are several ways to do it:
You need to create DNS alias aka CNAME record for sub.domain.com for redirecting to sub.domain.org (look here ( http://en.wikipedia.org/wiki/CNAME_record ) for more info). You won't need to do any moves on .com server.
You can redirect with web-server configuration. So sub.domain.com will refer to .com server and web-server will redirect it to .org. For example virtual host in apache it will look like that.
ServerName sub.domain.com
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://sub.domain.org/ [R=302,L]
Last way is redirect via website files. For example you can put index.php (if you're using php) and place in it:
Or proxy it via web-server like `nginx`. upd. as #intense suggested.
ps. I think 302 is the right variant. Not 301 =)