First and foremost, thank you for your time with my question.  I am attempting to forward all traffic from http:// and https:// to "https:&#47;&#47;www.[domain].com/[etc]"  I am currently able to force all "www." traffic to "https:&#47;&#47;www." using the setup in httpd.conf below:  &lt;VirtualHost *:80&gt; RewriteEngine On RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule ^.*$ https://{%SERVER_NAME}%{REQUEST_URI} &lt;/VirtualHost&gt;   This setup is unfortunately inconsistent.  If for instance I enter "https:&#47;&#47;[domain].com" into a browser address bar, it will not redirect.  On some browsers, "http:&#47;&#47;[domain].com" will redirect to the non-www "https:&#47;&#47;[domain].com" as well.  Long story short, I am having trouble setting up a proper redirect from any domain prefix to "https:&#47;&#47;www" on an Amazon EC2 Instance within the httpd.conf file.  If you can help me out here, I'd really appreciate it.  Thank you again for your time.  Edit: There is another Q&amp;A that goes over general rewrite rules, however there are some specific rules for the Amazon EC2 (ELB) that are not covered in that answer. Frankly, I'm not sure if the Amazon EC2 specifics apply to my question, but the code I have (x-forwarded-proto) is specific for the ELB.  For what it's worth, I'm asking this question because all of my resources have been exhausted.  If I found (or find) an answer somewhere else, I will happily update my question with information and a link.  Edit2:  The following code redirects from [domain].com, http:&#47;&#47;[domain.com], and http:&#47;&#47;www.[domain].com to https:&#47;&#47;www.[domain].com.  Unfortunately https:&#47;&#47;[domain].com still does not redirect.  &lt;VirtualHost *:80&gt; RewriteEngine On RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule ^.*$ https://{%SERVER_NAME}%{REQUEST_URI}  RewriteCond %{HTTP_HOST} !^www\. RewriteCond %{HTTPS}s ^on(s)| RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] &lt;/VirtualHost&gt;   Is there a different VirtualHost I need to have set up for the https:// domain redirect?
487
This is a  about Apache's mod_rewrite.   Changing a request URL or redirecting users to a different URL than the one they originally requested is done using mod_rewrite. This includes such things as:   Changing HTTP to HTTPS (or the other way around) Changing a request to a page which no longer exist to a new replacement. Modifying a URL format (such as ?id=3433 to /id/3433 ) Presenting a different page based on the browser, based on the referrer, based on anything possible under the moon and sun. Anything you want to mess around with URL   Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask!  How can I become an expert at writing mod_rewrite rules?   What is the fundamental format and structure of mod_rewrite rules? What form/flavor of regular expressions do I need to have a solid grasp of? What are the most common mistakes/pitfalls when writing rewrite rules? What is a good method for testing and verifying mod_rewrite rules? Are there SEO or performance implications of mod_rewrite rules I should be aware of? Are there common situations where mod_rewrite might seem like the right tool for the job but isn't? What are some common examples?   A place to test your rules  The  web site is a great place to play around with your rules and test them. It even shows the debug output so you can see what matched and what did not.
26009
I'm currently trying to set up a small static website with my domain from NameCheap using AWS S3, but I'm having trouble correctly pointing requests to the corresponding S3 bucket.  These are my configurations for the services I use:  NameCheap  CNAME         www  example.com.s3-website-ap-northeast-1.amazonaws.com. URL Redirect  @    http://www.example.com/   AWS S3  Static Hosting example.com.s3-website-ap-northeast-1.amazonaws.com.   I am fairly new to web hosting/domain stuff so please bear with me, but from what I understand from my registrar configuration is: users entering the naked domain example.com are redirected to www.example.com which then points to the AWS S3 bucket. Then the CNAME record then points to the corresponding AWS bucket.  Howeverwhen I try to visit www.example.com I somehow get pointed to the www.example.com bucket instead of the example.com bucket landing me to the AWS Bucket not found page.  Extra Details   I've checked with DNS Checker that www.example.com's CNAME record indeed points to example.com.s3-website-ap-northeast-1.amazonaws.com.. I've also tried making a www.example.com bucket then redirecting it to example.com but it seems it points to the actual domain instead of the bucket therefore causing a redirect loop. example.com-&gt;www.example.com-&gt;www.example.com (Bucket)-&gt;example.com-&gt;∞
17398
I have Apache 2.2 with mod_ssl and a bunch of sites in HTTPS on the same IP/port with VirtualHosting, so client must support SNI to connect to those virtual hosts.  I would like to configure my server the following way:  When a user types www.dummysite.com and his browser supports SNI (Server Name Indication), any HTTP request is redirected to https:// where an HSTS header is sent. But if the browser doesn't support SNI then the request is served by HTTP.  The above rule, stated as is, is actually a fallback rule for those people that still run old browsers, as Mozilla and Chrome don't have this problem, just to avoid leaving these users out of the site.  I would like to do this redirecting at the Apache config level, perhaps with a filter on the user agent. I wouldn't like to touch running applications except making sure that no direct http:// references are present (otherwise they imply a security warning)  [Edit] (while editing the question I forgot the question): what is the list of SNI-enabled user agents to redirect?
56052
I tried to setup apache 2.2 in amazon aws using amazon ami. i did installed httpd and php and congirue http.conf to use /var/www/html.  Then put file index.html on that folder. But when i tried to use browser to browse my domain which is ec2-122-248-255-181.ap-southeast-1.compute.amazonaws.com, nothing was loaded.  I did start httpd by running apachectl start, and i can see it listening on port 80.  Does anybody know what is wrong?
20336
On IIS 7.5 I am trying to achieve this with two websites:  Default Web Site is bound to:  (blank host header port 80 - http) (blank host header port 443 - https) go.example.com www71.example.com the IP address of go.example.com  2nd web site "Beta" is bound to:  beta.example.com (blank host header port 443 - https) * using blank only because it doesn't seem to be possible to    bind https to a named host header   And both need to work with SSL.  But I have these problems:   When I type in beta.example.com, I see the go.example.com site instead I can not seem to add the SSL binding to both websites at once (I have a single *.example.com wildcard certificate).  The beta site will not even start if I add the https binding to it.   This is how I have set it up:    What is the correct way to set it up?
59079
Here is what I have got:   CentOS 5.4 (32-bit)    installed Apache httpd (Server version: Apache/2.2.11 (Unix)) mod_rewrite already presents   Question: how to redirect simple  to  not using VirtualHost defines?  PS: tried to find in later answers on SF, but doesn't find nice solution.  Thanks.
11157
I'm moving from HTTP to HTTPS for my entire site. The site is currently added to Google Search Console (formerly Google Webmaster Tools) as www.example.com and all the pages are indexed without using SSL.  How do I go about moving to the new HTTPS URLs on Google Search Console?   Do I just submit an updated sitemap which has the HTTPS URLs or do I add a new site as https://www.example.com and submit the sitemap with HTTPS URLs? All current URLs are set to redirect to their HTTPS counterparts. Do I add multiple properties to Google Search Console?
20987
I have some subdomains I want to redirect to specific ports on the same server. Say I have  dev.mydomain.com    I want dev.mydomain.com to transparently redirect to mydomain.com:8080 and I want to preserve the original sub-domain name the url of the browser.  How do I do this with Apache 2.2? I have Apache 2.2 running on default port 80. I can't figure out the write configuration to get this to happen.  I have already set up dev.mydomain.com to resolve in DNS to mydomain.com.     This is for an intranet development server that has a non-routable ip   address so I am not so concerned about exploits and security that   would compromise a publicly facing server.
64079
I host my site at domain.com.  My DNS entries in Route53 are as follows:  domain.com      A       xxx.xxx.xxx.xxx      300 domain.com      NS      stuff.awsdns-47.org  172800 domain.com      SOA     stuff.awsdns-47.org  900   I would like to redirect traffic from www.domain.com to domain.com, as currently this just returns a 404.  suggested a PTR record, and I added that:  www.domain.com  PTR     domain.com           300   but it didn't work. What should I be doing?
94032
I want to Redirect as seen below:  https://example.com/p1/p2?sort=p.model&amp;order=ASC&amp;page=2   to  https://example.com/p3/p4?sort=p.model&amp;order=ASC&amp;page=2   Also, I have this code in my .htaccess file :  RedirectMatch 410 ^/p1/p2&amp;   I have used below code, but I just see 410 code for that URL :  RewriteRule ^/p1/p2?sort=p.model&amp;order=ASC&amp;page=2$ /p3/p4?sort=p.model&amp;order=ASC&amp;page=2 [QSD, R=301,L]   So, I have changed RedirectMatch 410 ^/p1/p2&amp; to Redirect 410 ^/p1/p2&amp; , but this time I have seen 404 Code for my Request URI. What should I do?
60065
I need to forward existing subdomain links to the root domain as the subdomain no longer exists. I have tried so many different lines of code in my .htaccess file and can not get the redirect to work.  The links to the subdomain look like: http://sub.example.com/dir/y99bb4  Can anyone suggest any code for me?
111543
I am trying to forward a subdomain to directly connect to a Minecraft server. The domain name is hosted at GoDaddy and the server requires the port at the end. These are the things I have tried so far:   I attempted to create an A record via GoDaddy's DNS manager. This worked in redirecting the IP, as the IP for the server is actually the IP for the server's control panel. I attempted to add this to Minecraft followed by :25602 which is the port number. Unfortunately that didn't work. I went to the GoDaddy domain management page and attempted to create a redirect to the subdomain but that did not work either. I entered the port name as well.   Does anyone know how to do this successfully? I mean to me, these things should have worked. I have done some research and can't seem to find anything other than what I have tried already.
40016
In preparation for the eventual deployment of full HTTPS support on Stack Exchange, and also to make the currently available "alpha" HTTPS support more usable, all links from Stack Exchange sites to other Stack Exchange sites should be .  Currently, at least the following places still feature links with explicit http: protocol prefixes:   the page footer, the "Hot Network Questions" and "Community Bulletin" modules in the sidebar,  (the site switcher menu is OK, though),   and, of course,   lots and lots of user-supplied links in post and comment content.   I've posted this feature request with the intent to provide a single central place for tracking these issues, rather than having them scattered across multiple meta threads.  If you find more places on SE where protocol-relative links should be used, please report them below.  I fully expect this request, in its full sense, to be treated as  for the time being; however, these issues do need to be fixed at some point before our HTTPS support is ready for "prime time".  Ps. Yes, the next release of  (v1.10) is going to include a general client-side fix for most of these issues.  In the mean time, the  plugin effectively provides the same functionality, and much more besides.
58113
I have one website. I have two domain names that I want to point to the same site install.   So whether you go to name-one.com or name-two.com you see the exact same site.  Now, I can either set up name-two.com to serve 301 redirect header redirecting to name-one.com – or, I can set up name-two.com as a CNAME in the DNS pointing to name-one.com  What is the different implications for SEO on this? What is recommended?  I would guess it's better for branding to use a 301 redirect, so that visitors will see one consistent url for my site, right?  The reason I want the two domains is that I want a version with regional letters ('ö' instead of 'oe' ) in the name.
27562
It's the following part of a virtual host config that I need further clarification on:  &lt;VirtualHost *:80&gt;   # Admin email, Server Name (domain name), and any aliases   ServerAdmin example@example.com   ServerName  141.29.495.999   ServerAlias example.com ...   This is and example config, similar to what I currently have (I don't have a domain name at the moment).  &lt;VirtualHost *:80&gt; - Allow the following settings for all HTTP requests made on port 80 to IPs that this server can be contacted on. For instance, if the server could be accessed on more than one IP, you could restrict this directive to just one instead of both.  ServerName - If the host part of the HTTP request matches this name, then allow the request. Normally this would be a domain name that maps to an IP, but in this case the HTTP request host must match this IP.  ServerAlias - Alternate names accepted by the server.  The confusing part for me is, in the above scenario, if I set ServerAlias mytestname.com and then made an HTTP request to mytestname.com, there would have to be a DNS record pointing to the server's IP for this to work? In which case, is ServerAlias just basically EXTRA ServerName entries?  Say I had a DNS entry such that foobar.com = 141.29.495.999 but then I had ServerName = 141.29.495.999 and ServerAlias was empty, would that mean that although foobar.com gets resolved to the right IP, because there is no reference to accept foobar.com in ServerName or ServerAlias?  Or something. Man I'm confused.
55595
Suppose I have a domain, foo.com where I have a series of pages like foo.com/123 and foo.com/456 etc.  I want to use the domain and provide links without a www prefix.  These pages also will have links to other pages (and each other) without the www prefix.  I'm using Azure to host our site which is the same as EC2 in that the domain cannot have an A record because the server environment is virtualized. So both Microsoft and Amazon tell you to use CNAME records to point your domain to an A record they manage.  In the case of Azure, my CNAME record points to a cloudapp.net record (which microsoft manages):  foo.com  CNAME  foo.cloudapp.net   where foo.cloudapp.net is my domain I've setup on Azure.  I'm encountering all sorts of problems with various things like email delivery and various people not being able to load the site.  2 different nameserver providers and my hoster tells me that it violates the RFC to have a root domain be a CNAME entry which is why my problems are sporadic.  I'm surprised to hear this as you see so many sites these days hosted on EC2 or Azure, and do not use a www prefix.  How are these sites setup so that they can use just foo.com (without www prefix)?  Update: While I asked the question about EC2 or Azure, I'm specifically looking for info on Azure.
590
I would like to redirect www.example.com to example.com. The following htaccess code makes this happen:  RewriteCond %{HTTP_HOST} ^www\.example\.com [NC] RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]   But, is there a way to do this in a generic fashion without hardcoding the domain name?