For some reasons i am trying to Redirect all traffic coming to port 443 to port 80 i.e from https to http and kindly this is not duplicate because i searched a lot but did not found any working solution. I created the following .htaccess file in root folder  RewriteEngine On  RewriteCond %{SERVER_PORT} 443  RewriteRule ^(.*)$ http://www.localhost.com/$1 [R,L]   this is not working but my .htaccess file is being read correctly i confirmed it by running following tests   I put random garbage character and Server shows error 500 The reverse of above code is working i.e Properly redirecting from http to https   If any one has experienced this before then kindly guide me to the solution  Best Regards!
123352
I used to operate a website with an SSL certificate, but have stopped using the SSL certificate. The problem is that most of the external links to the website use the https:// prefix.  I have tried the https:// to http:// redirect in the .htaccess file:  RewriteEngine On  RewriteCond %{HTTPS} on RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI}   But it seems, as has been pointed out elsewhere, that the server is trying to retrieve the certificate before activating the redirect. Hence, an error is shown before the redirect is ever accomplished. The error is either a warning that the certificate is expired, or if I delete the certificate signing request, then an error that SSL received a record that exceeded the maximum permissible length.  Is there any way to allow the incoming links to be redirected properly?
57765
Compare these two RedirectMatch's. The first doesn't work: RedirectMatch 302 ^/redirect\.php[?]page=(.+)$ http://somewhereelse.com/$1  Versus this, which will redirect to http://somewhereelse.com/?page=wherever: RedirectMatch 302 ^/redirect\.php([?]page=.+)?$ http://somewhereelse.com/$1  Does RedirectMatch only match the URI and not the query string? Apache's documentation is a bit vague in this area. What I'm trying to do is extract the page query parameter and redirect to another site using it. Is that possible with RedirectMatch or do I have to use RewriteCond + RewriteRule?
35370
I have a PHP application (Wordpress) in the root folder of my site, and all requests to the site run through it happily.   However, I have a subfolder, _links, which I would like to use to execute another, different php script.  Eg, if a user goes to site.com/_links/221312, then the index.php script from /_links takes over.  I formerly used a .htaccess file to achieve this, but since moving to nginx I can't make it work.   Here is the old .htaccess file.  RewriteEngine On RewriteRule    ^([0-9]+)/?$    index.php?linkid=$1    [NC,L]   Obviously, I'm passing the last bit of the URL to the script as a parameter.  Here is my nginx config. Requests to eg site.com/_links/23423 are picked up by if (!-e $request_filename) and rewritten to /index.php?q=/_links/23423 instead of being picked up by the location block.   server {         listen  127.0.0.1:8080;         server_name site.com www.site.com m.site.com;          root /var/www/site;         location ^~ /_links/ {                 add_header location 1;                 root /var/www/site/_links;                 rewrite "^([0-9]+)/?$" /index.php?linkid=$1 break;                 location ~ \.php$ {                         try_files $uri =404;                         fastcgi_pass unix:/var/run/php5-fpm.sock;                         fastcgi_index index.php;                         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;                         include fastcgi_params;                  }          }         index index.php index.html;         if (!-e $request_filename)             {                 rewrite ^(.+)$ /index.php?q=$1 last;             }         location / {                 try_files $uri $uri/ =404;         }          # pass the PHP scripts to FastCGI server listening on the php-fpm socket         location ~ \.php$ {                 try_files $uri =404;                 fastcgi_pass unix:/var/run/php5-fpm.sock;                 fastcgi_index index.php;                 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;                 include fastcgi_params;          }         access_log /var/log/nginx/site.com.access.log;         error_log /var/log/nginx/site.com.error.log notice; }   I'm really confused. What's going on here?
31987
In my site I'm redirecting everything (http://, http://www., https://) to https://www.example.com.  Google webmaster tools says: Make sure you add both "www" and "non-www" versions for your site. Also, if you use the HTTPS protocol, add those variations as well.  So I've added all the FOUR versions to google webmaster tools. Is this a correct process?
92263
I want to redirect all traffic from port 443 to the internal port 8080. I'm using this config for iptables:  iptables -t nat -I PREROUTING --source 0/0 --destination 0/0 -p tcp \          --dport 443 -j REDIRECT --to-ports 8080   This works for all external clients. But if I'm trying to access the port 443 from the same maschine I'll get a connection refused error.  wget https://localhost   How can I extend the iptables rule to redirect local traffic too?
121104
In Nginx we have been trying to redirect a URL as follows:  http://example.com/some/path -&gt; http://192.168.1.24   where the user still sees the original URL in their browser. Once the user is redirected, say they click on the link to /section/index.html, we would want this to make a request that leads to the redirect  http://example.com/some/path/section/index.html -&gt; http://192.168.1.24/section/index.html   and again still preserve the original URL.  Our attempts have involved various solutions using proxies and rewrite rules, and below shows the configuration that has brought us closest to a solution (note that this is the web server configuration for the example.com web server). However, there are still two problems with this:   It does not perform the rewrite properly, in that the request URL received by the web server http://192.168.1.24 includes /some/path and therefore fails to serve the required page. When you hover on a link once a page has been served, /some/path is missing from the URL  server {     listen          80;     server_name     www.example.com;      location /some/path/ {         proxy_pass http://192.168.1.24;         proxy_redirect http://www.example.com/some/path http://192.168.1.24;         proxy_set_header Host $host;     }      location / {         index index.html;         root  /var/www/example.com/htdocs;     } }    We are looking for a solution that only involves changing the web server configuration on example.com. We are able to change the config on 192.168.1.24 (also Nginx), however we want to try and avoid this because we will need to repeat this setup for hundreds of different servers whose access is proxied through example.com.
55363
I am able to do a reverse port forwarding through the PUTTY GUI with settings similar to below. Once I apply this setting, I am able to run to the server box and run wget http://localhost:8080 &lt;-- a quick and dirty way to verify that the port is being forwarded.    However I am unable to make it working when I am using the command line.    --  When I tried using the most basic reverse port forwarding commands in ssh, it just does not work  the few examples which I have tried  ssh -R 8080:localhost:80 root@debian-tunnel-a1 ssh -g -R 8080:localhost:80 root@debian-tunnel-a1  ssh -f -g -R *:8080:localhost:80 root@debian-tunnel-a1 -p 22   Basically I've tried all samples I can find online for the past two days and they all don't work.  If I use the most commonly used commands which I've show above, I always get the error in the picture below:    As I try use a basic wget http://localhost:8080  On the SERVER machine (I am using wget http://localhost:8080 as a way to verify that Device #1 's port 80 is being forwarded to the Server device #2's port 8080, and that I can access it directly), the device #1 which I use the reverse port command basically spit out this error above.  It seems like the connection LINK is established, but the reverse port machine is not allowing it to go through.  But the puzzling thing is I am able to get it working under GUI, but just not command line.    To have a full picture of what the goal is:  device #1 share port 80 to------> server device #2 --------->  device #3 (talks to device #1 through server with server being the middleman)  I am still stuck on the first portion of  (device #1 ---> server device #2)   once I am completed, then I will   relay device #1  to  device #3  with server device #2 acting as middleman.
115072
I have several servers running on the same machine, some with http only, some with both http and https.  There are several server blocks defined in separate files which are included from the main config file.  I have set up a "default" server for http which will serve a generic "maintenance page" to requests that don't match any of the other server_names in the other config files.  The http default server works as expected, it uses the server_name "_" and it appears first in the list of includes (because I have observed that in the case of duplicate server_names across servers, the one appearing first is used).  This works great.  I would expect the same exact server block (only switching "listen 80 default_server" to "listen 443 default_server" and also instead of serving page "return 444") however it does not.  Instead, it appears that the new default https server is actually grabbing all incoming https connections and causing them to fail, although the other server blocks have more appropriate server_names for the incoming requests.  Removing the new default https server will cause semi-correct behavior to resume: the websites with https will all load correctly; but the websites without https will all be routed to the first https server in the include files (which according to the docs, if no "default_server" appears, then the first server block to appear will be "default").  So my question is, what is the correct way to define a "default server" in nginx for ssl connections?  Why is it that when I explicitly set a "default_server" it gets greedy and grabs all connections whereas when I implicitly let nginx decide the "default server" it works like I would expect (with the incorrect server set as default and the other real servers behaving correctly)?  Here are my "default servers".  Http works without breaking other servers.  Https breaks other servers and consumes all.  server {     listen 443 ssl default_server;     server_name _;      access_log /var/log/nginx/maintenance.access.log;     error_log /var/log/nginx/maintenance.error.log error;      return 444; }  server {     listen *:80 default_server;     server_name _;     charset utf-8;      access_log /var/log/nginx/maintenance.access.log;     error_log /var/log/nginx/maintenance.error.log error;      root /home/path/to/templates;      location / {         return 503;     }      error_page 503 @maintenance;      location @maintenance {         rewrite ^(.*)$ /maintenance.html break;     } }   Any of you see what might be wrong here?
68785
I'm trying to set up OpenVPN to listen on port 443, and then pass all HTTPS traffic to Apache, by using the port-share option. Relevant config snippets are: OpenVPN local ${PUBLIC_IP} port 443 port-share localhost 443  Apache with SSL Listen localhost:443  My OpenVPN client connects just fine, but when opening the HTTPS enabled page, I get errors. Firefox says:  SSL received a record that exceeded the maximum permissible length. (Error code: ssl_error_rx_record_too_long)  Curl says  curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol  The request ends up on Apache, since I see in the error logs the following messages: [Wed Oct 06 01:10:20 2010] [error] [client 127.0.0.1] Invalid method in request \x16\x03\x01 [Wed Oct 06 01:11:04 2010] [error] [client 127.0.0.1] Invalid method in request \x16\x03\x01 [Wed Oct 06 01:11:51 2010] [error] [client 127.0.0.1] Invalid method in request \x16\x03\x01  The messages entry for a HTTPS connection is Oct  6 01:13:21 ns1 openvpn[20154]: Re-using SSL/TLS context Oct  6 01:13:21 ns1 openvpn[20154]: LZO compression initialized Oct  6 01:13:21 ns1 openvpn[20154]: Control Channel MTU parms [ L:1544 D:140 EF:40 EB:0 ET:0 EL:0 ] Oct  6 01:13:21 ns1 openvpn[20154]: Data Channel MTU parms [ L:1544 D:1450 EF:44 EB:135 ET:0 EL:0 AF:3/1 ] Oct  6 01:13:21 ns1 openvpn[20154]: Local Options hash (VER=V4): 'c0103fa8' Oct  6 01:13:21 ns1 openvpn[20154]: Expected Remote Options hash (VER=V4): '69109d17' Oct  6 01:13:21 ns1 openvpn[20154]: TCP connection established with ${CLIENT_IP}:56203 Oct  6 01:13:21 ns1 openvpn[20154]: TCPv4_SERVER link local: [undef] Oct  6 01:13:21 ns1 openvpn[20154]: TCPv4_SERVER link remote: ${CLIENT_IP}:56203 Oct  6 01:13:21 ns1 openvpn[20154]: ${CLIENT_IP}:56203 Non-OpenVPN client protocol detected Oct  6 01:13:21 ns1 openvpn[20154]: TCP/UDP: Closing socket  Using httpd-2.2.3-43.el5.centos and openvpn-2.1.1-2.el5 . What should I do to make port sharing work?  Update: Using port 443 port-share localhost 10443  and Listen localhost:10443  makes no difference.  Update 2 : some command output [root@ns1 ~]# openvpn --help | grep port-share --port-share host port : When run in TCP mode, proxy incoming HTTPS sessions [root@ns1 ~]# netstat -nltp | grep 443 tcp        0      0 127.0.0.1:10443             0.0.0.0:*                   LISTEN      20088/httpd          tcp        0      0 ${PUBLIC_IP}:443             0.0.0.0:*                   LISTEN      20066/openvpn
48829
This is a  about redirecting from http to https in Apache Related:     I have an Appache web server which serves both http://example.com/ and https://example.com/. I want to redirect all http requests to https. Currently I'm using this .htaccess rule to redirect http requests to https. RewriteEngine On RewriteBase / RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}   It's working as expected for example.com but the same rule is not working for sub links, when I access existing links, like example.com/about it will still load in http, no redirection happens for existing links. How can I make Apache redirect all http requests to https?
111579
With the release of Chrome Version 44.0.2403.89 m, I've noticed that our site is now completely broken. All of the HTTP URLs are being redirected to HTTPS URLs, which is a problem because our site does not support HTTPS.   Please note, this is not happening in any other browser, and was working on the previous Chrome release.  I've tried to replace all of our stylesheet calls with relative links, and that has worked, but the images that are loaded in automatically or through absolute paths as well as the navigation is still broken. Please see below image for the error page that is thrown when navigating, after accepting the security warning and proceeding.    Anyone have any advice as far as updating perhaps the .htaccess file goes, or something in functions?  Thanks.
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?
59364
We have a busy website where we never used SSL. Recently its indexed by Google as https://www.example.com.  The users are getting security certificate errors.   In google webmaster tools we can only remove the relative URL. For example, any thing after http://www.example.com.   I am using IIS 6.0 to host the site .net website.   I have seen similar posts here and there and almost all of them recommend a redirect. I don't want to set up a redirect as it will slow down the site loading. I guess I would also need to setup a new website on IIS  with HTTPS protocol and then do the redirect to HTTP site?
90488
I would like to redirect a URL with uppercase characters http://localhost/A/B to a lowercase version http://localhost/a/b using the .htaccess file. Using regex I can capture A and B but is it possible to convert them to lowercase?
19960
I'm running a website which is acting extremely strange.   At the time of writing, this link works: http://www.example.com This link doesn't: http://example.com  But it does work if you copy/paste it and run it in Incognito... This link (after ignoring a warning) serves a totally unrelated and unknown website: https://example.com    I have no idea how to debug this issue. I have contacted the hosting and domain company to investigate the issue. How is the last issue even possible?
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?
12186
We run an ecommerce site that was setup by a third party ecommerce software provider, basic shop with product pages, basket and checkout.  The third party vendor set up the htaccess file so that if a non-existent URL is enetered it redirects to the homepage instead of a 404 error being generated.  This results in google webmaster reporting duplicate titles and descriptions for pages that no longer exist.  I think that it would be better for a dedicated 404 error page to be displayed rather than redirecting back to the homepage  So is it better to have a website redirect a 404 to the homepage than have a dedicated 404 page instead?