How to redirect from old domain to a new subdomain by .htaccess file in openshift rhc - apache

I have two sites in openshift rhc. For the first one I use cloudflare and tk domain by name of www.elasa.ir and set my first site by the name of first.rhcloud.com .
I want to have a sub domain for the first domain similar to dl1.example.com that redirects to the second site in openshift rhc.
I added the dl1.example.com in the secondry site in openshift rhc as a CNAME, and set it to secondery-.rhcloud.com to shope.elasa.ir
and in cloudeflare in setting of example.com.
I added a CNAME record for pointing shope.elasa.ir to secondery-.rhcloud.com
and finally by clicking to dl1.example.com it showing the secondary site, but after another clicking the address-bar change to secondery-.rhcloud.com.
So what i must to do for redirecting the secondery-.rhcloud.com to subdomain (dl1.exmple.com) for all the time:
I added an .htaccess file with this code:
Options +SymLinksIfOwnerMatch
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?tomatocart-beyhagh.rhcloud\.com$ [NC]
RewriteRule ^(.*)$ "http\:\/\/shope\.elasa\.ir\/$1" [R=301,L]
but I get the following error:
The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for
this address in a way that will never complete.
This problem can sometimes be caused by disabling or refusing to accept cookies.

You can just create a alias domain in OpenShift console and redirect to your subdomain.
Use cloudflare to create your subdomain and setting a CNAME to secondery-.rhcloud.com.

Related

How to Load My Non-Public Site via HTTP (No SSL Config) - All Browsers Auto-Redirect to HTTPS

I need to load my website via HTTP, but all browsers automatically redirect to HTTPS. I have no SSL setup on the site (the domain name is not registered anywhere), nor is the server expecting SSL (AFAIK).
I also run into this when I register a new domain name or make DNS changes for a site and set the IP in my hosts file before the DNS records can propagate, but this is usually resolved within an hour or two.
I manually added a development domain to my servers (not registered anywhere) and manually added the domain to my hosts file.
123.456.789.1 example.dev
I never setup SSL or HTTPS on the server for the domain, but Chrome/Edge/Firefox refuses to load the site over HTTP.
It is a WordPress installation, and I have the URL set to http://example.dev.
option_id | option_name | option_value | autoload
1 | siteurl | http://example.dev | 1
I tried deleting the HSTS settings on the domain in the browser via (chrome|chromium|edge)://net-internals/#hsts.
I set up a 301 to HTTP from HTTPS in the .htaccess file on the site, and a couple other things that escape my memory at this time.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} =on [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
Still, no luck. What else can I do to force HTTP on my non-public site?
EDIT:
It seems as though Chrome now requires all *.dev to have HSTS and HTTPS. I have since begun using a *.test domain name, and my issues are resolved.
HSTS is forced on .dev domains by the browsers.
You will have to use a different domain or set up HTTPS for your web server.
https://ma.ttias.be/chrome-force-dev-domains-https-via-preloaded-hsts/

how to stop to use ssl on tuleap 9.1?

On centos 6, tuleap 9.1, after installation I am only able to access the main page on http, the rest is not available because each links are root on https. Is there's a way to deactivate ssl completely?
I installed all, now can access to the first presentation page, but only if I use http and not https. Problem all the rest of the link of page ( create account, connexion etc...) redirect to https. I already try to deactivate https without success.
Can anyone can help to disable https and is stopping using ssl definitely can generate issue when using this tool?
You could force your website to only load on HTTP through your .htaccess file:
RewriteEngine On
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ http://www.{HTTP_HOST}%{REQUEST_URI} [R=302,L,NE]
I've included www in the Rewrite, if you don't want that then you can remove that section. I've also set R=302so that it is a temporary redirect. Set this to R=301 once you know it is working, as that will make it permanent.
Make sure you clear your cache before you test this.

https before address shows only files in private_html folder on host

when i try my webpage address with https, page shows only files in the private_html folder not public_html.
but my website runs in the public_html. for example i use an index.html file (including forwarder script) and when you type https://alirezah.net it redirects to http://alirezah.net.
how can i fix it? I wanna use cloudflare ssl service but this happens.
I tried to edit htaccess but it doesn't help
If your website is hosted on Directadmin, then follow these steps:
Log in to your DirectAdmin control panel
Click on Domain Setup
Click on the domain name you wish to change this for
Choose the Use a symbolic link from private_html to public_html - allows for same data in http and https checkbox.
Note the warning message - anything in private_html will be removed, so be sure you do not have content left here that you want to keep.
Accept the warning notice and your now pointing you are private_html directory to the public_html directory.
If your website is installed in private_html it will be deleted using this function. If you want to keep your website installed in private html and also redirect http to https, then you need to create a .htaccess file in public_html with the following contents:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule .* https://example.com/%{REQUEST_URI} [R,L]

Allow access from domain name only with Apache

I have a bunch of scripts on a server running Ubuntu 12.04 and Apache. Currently, I can access the site both ways: via the IP and the domain name, for example: http://example.com and http://1.1.1.1 where example.com has an A record pointing to 1.1.1.1. My question is, is there a way to throw 403 or similar error when the site is accessed by the server IP and not by its domain name?
All I could find about my question is a link to the Apache HOW-TOs, however, there is no information on how to achieve this whatsoever. My assumption is that I have to edit the configuration file of the default vhost, but I don't know what exactly to change. Or perhaps there's a module for it?
Put this rule in your vhost configuration
RewriteEngine on
RewriteCond %{HTTP_HOST} ^1\.1\.1\.1$
RewriteRule ^ - [F]

Apache rewrite rule with proxy flag fail to work for mediawiki service

I have a local apache httpd hosting a mediawiki service that listen to port 3300. The service may access in my LAN via
http://mylan:3300/wiki/
I configure my internet router to add a port forwarding entry to the mylan:3300. I may then access to the wiki via something like:
http://<dynamic domain>:3300/wiki/
Next, I have a web site that serve globally. The web server is apache httpd too. I add a rewrite rule in .htaccess:
RewriteEngine On
RewriteRule ^/?wiki/?$ http://<dynamic domain>:3300/wiki/ [P]
I wish to access the wiki that host on my local LAN via the proxy method but using the global internet domain namespace:
http://<internet domain>/wiki/
After execute the above URL from internet browser, I can see the wiki contents. However, the URL shown in address bar change to
http://<dynamic domain>:3300/wiki/index.php/Main_Page
In order to test the proxy rewrite rule work, I try to change the rewrite rule to:
RewriteRule ^/?wiki/?$ http://www.google.com/search?q=test [P]
Open the URL:
http:///wiki/
lead me to google search page but the URL remain as http:///wiki/.
Any ideas why the rewrite rule
RewriteRule ^/?wiki/?$ http://<dynamic domain>:3300/wiki/ [P]
make the browser show the new URL address instead of internet domain name space:
http://<internet domain>/wiki/
A good example is:
RewriteRule ^/?wiki/(.*)$ http://en.wikipedia.org/wiki/$1 [P]
If we access the url:
http://<domain>/wiki/Country
The URL will always rewrite and shown as
http://en.wikipedia.org/wiki/Country
Instead, I expect it to show as
http://<domain>/wiki/Country
but the content is from http://en.wikipedia.org/wiki/Country
Probably a redirect that includes the full link. To rewrite them add something like:
ProxyPassReverse /wiki/ http://<dynamic domain>:3300/wiki/
I also notice in the Apache online documentation for URL Rewriting Guide - Advanced topics in the section on Content Handling, sub section Dynamic Mirror has this example:
RewriteEngine on
RewriteBase /~quux/
RewriteRule ^hotsheet/(.*)$ http://www.tstimpreso.com/hotsheet/$1 [P]