no-www

NodeJS Redirect all non-www to www except subdomains

坚强是说给别人听的谎言 提交于 2019-12-02 02:22:02
问题 any idea on how i can do this in Express 3.0? As the non-www url is causing very odd problems in different areas of the website. Thanks! 回答1: The answer didn't work for me. I've used the following code (http://redirect-www.org/#nodejs): //REDIRECT www.domain.com TO domain.com app.get ('/*', function (req, res, next){ var protocol = 'http' + (req.connection.encrypted ? 's' : '') + '://' , host = req.headers.host , href ; // no www. present, nothing to do here if (!/^www\./i.test(host)) { next(

WWW to NON WWW Urls (Remove WWW) using Apache (.htaccess)

点点圈 提交于 2019-12-01 23:25:45
I have to redirect my website from https://www.example.com/ to https://website.com/ . SSL is properly installed on my server. I am using Apache and have to do this using Apache (either httpd.conf/ssl.conf or .htaccess ) I have used almost all of the methods I could search for but none of them work for me. http://www.example.com/ redirects properly to https://example.com/ http://example.com/ redirects properly to https://example.com/ . But https://www.example.com/ does not redirect properly to https://example.com/ . It gives me "invalid certificate error" and when I add an exception (accept the

NodeJS Redirect all non-www to www except subdomains

ぐ巨炮叔叔 提交于 2019-12-01 22:48:48
any idea on how i can do this in Express 3.0? As the non-www url is causing very odd problems in different areas of the website. Thanks! The answer didn't work for me. I've used the following code ( http://redirect-www.org/#nodejs ): //REDIRECT www.domain.com TO domain.com app.get ('/*', function (req, res, next){ var protocol = 'http' + (req.connection.encrypted ? 's' : '') + '://' , host = req.headers.host , href ; // no www. present, nothing to do here if (!/^www\./i.test(host)) { next(); return; } // remove www. host = host.replace(/^www\./i, ''); href = protocol + host + req.url; res

Redirect https to non-www and http to www

时光总嘲笑我的痴心妄想 提交于 2019-11-28 13:39:57
I need a combination of redirects to achieve the following: To redirect http://example.com to http://www.example.com , while redirecting https://www.example.com to https://example.com . I would like to force the www prefix do the domain name when the site is accessed over http . However the SSL certificate only works without the www . When accessed over https , I don't want the domain name to have the www prefix. The redirection from https://www.mysite.com to https://mysite.com can only happen after the client has made an initial request to https://www.mysite.com . For this initial connection

htaccess redirect domain to https, subdomain to http and www to non-www

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 10:32:59
I’m trying to do that: Force the https for my main domain. http or https://www.domain.com -> https://domain.com http or https://domain.com -> https://domain.com But not for subdomains http or https://www.subdomain.domain.com -> http://subdomain.domain.com http or https://subdomain.domain.com -> http://subdomain.domain.com And always removing the www. Now i have that: RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] This redirects www to non-www and http to https but not for

Remove www site-wide, force https on certain directories and http on the rest?

空扰寡人 提交于 2019-11-28 05:06:30
Firstly, I would like to remove the www. from my domain name http://www.example.com => http://example.com I would also like for certain directories to be secure (https), while the rest remain http http://example.com/login => https://example.com/login Obviously it needs to work for all conditions, for example if someone types in: http://www.example.com/login => https://example.com/login Also when people navigate away from the login page it returns to http. Currently in the .htaccess is the following which is done automatically by the software I am using and I suppose needs to be there for it to

Redirect https to non-www and http to www

↘锁芯ラ 提交于 2019-11-27 07:48:25
问题 I need a combination of redirects to achieve the following: To redirect http://example.com to http://www.example.com , while redirecting https://www.example.com to https://example.com . I would like to force the www prefix do the domain name when the site is accessed over http . However the SSL certificate only works without the www . When accessed over https , I don't want the domain name to have the www prefix. 回答1: The redirection from https://www.mysite.com to https://mysite.com can only

WWW to non-WWW Redirect with PHP

巧了我就是萌 提交于 2019-11-27 07:17:53
I want to redirect all www.domain.com requests to domain.com with PHP, basically: if (substr($_SERVER['SERVER_NAME'], 0, 4) === 'www.') { header('Location: http://' . substr($_SERVER['SERVER_NAME'], 4)); exit(); } However I do want to maintain the requested URL like in SO, for e.g.: http://www.stackoverflow.com/questions/tagged/php?foo=bar Should redirect to: http://stackoverflow.com/questions/tagged/php?foo=bar I don't want to rely on .htaccess solutions, and I'm unsure which $_SERVER vars I'd have to use to make this happen. Also, preserving the HTTPS protocol would be a plus. How should I

.htaccess Remove WWW from URL + Directories

荒凉一梦 提交于 2019-11-27 06:36:10
This seems to be a non-issue for many people (read: I can't find an answer), but I would like to update the following htaccess code to not only remove the 'www' from the URL, but also any sub-directories that are accessed. RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] With this, http://www.example.com/any/ resolves fine, but I want it to redirect to http://example.com/any/ as with the root. phpmonkey I had the same problem (trouble stripping 'www' from URLs that point to a sub-directory on an add-on domain), but after some trial and error,

htaccess redirect domain to https, subdomain to http and www to non-www

不羁的心 提交于 2019-11-27 03:47:04
问题 I’m trying to do that: Force the https for my main domain. http or https://www.domain.com -> https://domain.com http or https://domain.com -> https://domain.com But not for subdomains http or https://www.subdomain.domain.com -> http://subdomain.domain.com http or https://subdomain.domain.com -> http://subdomain.domain.com And always removing the www. Now i have that: RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] RewriteCond %{HTTPS} off RewriteRule (.*)