I create an application Jenkins on Openshift, but when I tried to visit http://[app_name]-[domain_name].rhcloud.com/, it will be redirected to https://[app_name]-[domain_name].rhcloud.com/.
I curl the http address, the result is :
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved here.</p>
<hr>
<address>Apache/2.2.15 (Red Hat) Server at [app_name]-[domain_name].rhcloud.com Port 80</address>
</body></html>
If I do not want to be redirected to https, what should I do?
I searched in my openshift folders, but cannot find any helpful things
You should change it on your .htaccess file.
RewriteRule ^https://[app_name]-[domain_name].rhcloud.com/(.*) http://[app_name]-[domain_name].rhcloud.com/$1 [R=301,NC]
Related
I have a site setup on Digital Ocean using their Wordpress droplet installer. I have then installed Jetpack.
The Site Health tool reported that Jetpack is not connected and that I should visit the Jetpack.com debugger. I did so and put my website in. The error I get:
XML-RPC is not responding correctly ( 200 )
When visiting the url mywebaddress.com/xmlrpc.php I just get redirected to the main URL of the site.
As recommended by Jetpack I went to a terminal and ran
curl -A 'Jetpack by WordPress.com' -d '<methodCall><methodName>demo.sayHello</methodName></methodCall>' https://mywebaddress.com/xmlrpc.php
When I do so I get the following coming back.
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved here.</p>
<hr>
<address>Apache/2.4.29 (Ubuntu) Server at mywebaddress.com Port 443</address>
</body></html>
I have checked the .htaccess file and this contains only comments.
I have checked /etc/apache2/apache2.conf and can find no redirects there.
So my question is, can anyone tell me what might be causing this 301 Redirect?
Found the answer
I have just located this file:
/etc/apache2/conf-enabled/block-xmlrpc.conf
This had this inside
<IfModule mod_rewrite.c>
<Directory / >
Redirect 301 /xmlrpc.php /
</Directory>
</IfModule>
This file was causing the redirect. Have commented out its contents for now.
I didn't create this, so I must assume DigitalOcean create it when doing the Wordpress one click install
I found this file under /etc/apache2/conf-available/ rather than /conf-enabled/
I tried to look around before posting but I wasn't able to found a solution for my issue.
I used to host a blog in a domain like http://example.com/blog and I moved it to the root /
What I'd like to do is to write a rule in NGINX telling to redirect my old articles from :
http://example.com/blog/my-dope-article
to
http://example.com/my-dope-article
Is there anyway to do that?
Thanks !
I tried this :
rewrite ^/blog/(.*) http://$server_name/$1 permanent;
But it doesn't work because http://example.com/blog/my-dope-article still got rewritten to http://example.com/blog/my-dope-article where I want to delete "/blog" part from the new URL.. :(
Have you looked at the redirects with curl or other tools to examine what exactly happens?
If you're running wordpress on / instead of /blog/ now but haven't yet changed the home- and siteurl-options, WP will create a redirect to the URL it thinks it is running at.
When you look at the headers (e.g. with curl -I http://example.com/ or by using the developer tools in your browser), you'll usually spot differences between redirects caused by nginx and redirects caused by whatever is behind nginx.
For example, a redirect by nginx itself might look like this:
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Tue, 03 Oct 2017 18:37:06 GMT
Content-Type: text/html
Content-Length: 178
Connection: keep-alive
Location: https://www.example.org/
While a redirect from apache/php/WP behind nginx might look like this
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Tue, 03 Oct 2017 18:39:44 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: keep-alive
Location: https://www.example.org/
Vary: Accept-Encoding
Content-Length: 339
Notice the moved Content-Length header, added Vary header and different Content-Type.
And, of course, you can look at the body they send with redirects as well (e.g. curl -v https://www.example.org/).
Example for nginx:
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>
apache/WP
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved here.</p>
<hr>
<address>Apache/2.2.16 (Debian) Server at example.org Port 80</address>
</body></html>
Yes I tried to CURL to see what happened. In the end, I found what I've done wrong: it was the syntax..
So I just put : rewrite ^/blog(.*) /$1 last; at the server directive in my nginx conf file and voilĂ
I'm trying to move to nginx from apache but one of the features I most use in apache are the ssi includes. I'm testing how nginx deal with ssi but I'm having some problems...
If an include virtual file doesn't exist I'm getting a 404 page embeded, not even the [an error has occurred] message. With apache ssi, if the file doesn't exist an error is shown as comment.
The other point is, with apache SSIErrorMsg directive I can set at server config level the error text but I couldn't find this in nginx, just the <!--# config errmsg="custom error" --> inside the html. I coudn't see a directive like SSIErrorMsg in nginx documentation
nginx 404 ssi error :
<html>
<head>
<title>simple</title>
</head>
<body>
<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.6.2</center>
</body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
</body>
</html>
but in apache:
<html>
<head>
<title>simple</title>
</head>
<body>
<!-- Error -->
</body>
</html>
The error message only appears in nginx when for instance I write a ssi include with some typo like
<!--#include virtualll="example.html"-->
Is there a way to show an error instead of embedding the 404 file in case of not found?
This is the nginx server config:
server {
listen 80;
server_name demo.localhost;
ssi on;
ssi_silent_errors off;
location / {
root /var/www/demoweb;
}
}
If I set ssi_silent_errors off; nothing is shown but I want something like <!--Error--> as apache does
So I have two Domains where one is just a domain without Webspace.
The other Domain shows to a Wordpress Installation which works fine. (www.braintwist.org)
I tried to Frame redirect the external Domain to this directory and it also works out.
(www.thebraintank.de redirected to www.braintwist.org)
The Site gets loaded in a Frameset. Unfortunatly, when I open up the site on a mobile phone the scale stays at desktop size (so the font-size is to "small" etc.)
I think its because the Frameset.
Is there a way to redirect the Domain to an external Webspace without it being loaded in a Frameset?
best regards
You could write a small php script like this (this would need to be stored as index.php and would only redirect users accessing the index.php or the "plain" domain as URL):
<?php
header('Location: http://newlocation'):
?>
or use a .htaccess file:
RewriteEngine On
RewriteRule (.*) http://newlocation/$1
or
Redirect / http://newlocation/
In the first place mod_rewrite must be loaded and for the second .htaccess example you need mod_alias.
However, in both cases you will see the new URL in the address bar of the browser.
In order to keep the URL on the addressbar you could use
RewriteEngine On
RewriteRule (.*) http://newlocation/$1 [P]
to proxy requests. This, however, requires mod_rewrite and mod_proxy to be loaded (and might cause some slower performance as all requests are done "twice" in background).
See: http://httpd.apache.org/docs/current/rewrite/ for mod_rewrite documentation.
Create a .php document and upload it to your hosting. Don't create a frame forward in your domain setting, but point the domain to the created .php document. Then use the following code in your .php document to create the frame forward there.
<html>
<head>
<title>Your Title</title>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-
scale=1.0; user-scalable=0">
<link rel='shortcut icon' type='image/x-icon' href='/favicon.ico' />
</head>
<frameset rows="100%" border="0" framespacing="0" frameborder="0">
<frame name="main" src="https://your-target-domain.com/" marginwidth="0"
marginheight="0" scrolling="auto"
noresize="noresize">
</frameset>
<noframes>
</noframes>
</html>
I created a link to a favicon as well. You can take this line out if you dont need it. If you need it, simply upload your favicon as "favicon.ico" into the same directory as the .php file.
Now you have a mobile responsive frame forwarding :)
This is a generic webhosting question,
I am trying to redirect, my primary domain to a subfolder in the 'www' folder, which consists of 3 folders
here is a better view
www ->
Folder1
Folder2
Folder3
Folder2 is where my drupal installation is , and this is where I want my domain to go directly
Right now what is happening is I type my domain name in the browser, abc.com, then I am presented with the above mentioned 3 folders and when I click the subfolder2, I can use drupal as per normal.
I am not sure what is needed to be changed, I am sure this can be done.
What sort of web server have you got? Is it one you are self hosting?
If it's apache you can change the home page to point to the new folder. HOWEVER if you are remotely hosting it this may be more difficult and you may have to physically move the whole installation to the root.
Another solution (not a nice one) is to do an HTTP redirect by creating an index.html in the home folder with
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Your Page Title</title>
<meta http-equiv="REFRESH" content="0;Folder2"></HEAD>
<BODY>
</BODY>
</HTML>
You can use .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?Primarydomain.com$
RewriteRule ^(/)?$ Folder2 [L]