Apache 2.4 maintenance html page image not loading - mod-rewrite

I am trying to implement maintenance page in apache 2.4 without restart and for specific 503 error code. I am following this site https://www.shellhacks.com/redirect-site-maintenance-page-apache-htaccess/
Below is my html file, image file maintenance.svg is also in same root htdocs folder:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body, html {
height: 100%;
margin: 0;
/* The image used */
background-image: url("maintenance.svg");
/* Full height */
height: 100%;
/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
</style>
</head>
<body>
</body>
</html>
ReWrite rule as below :
DocumentRoot "${SRVROOT}/htdocs"
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{DOCUMENT_ROOT}/maintenance.enable -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /maintenance.html [L]
ErrorDocument 503 /maintenance.html
I am not expert in Apache, Need your help to load image using rewrite rule.

The final RewriteCond is what's doing exceptions to the rewrite. You can add another and it is implicitly AND'ed with the previous ones:
RewriteCond %{REQUEST_URI} !maintenance.svg

Related

How configure virtual hosts on Nginx (on Windows)

I read some tutorials and also some topics how to config virtual hosts in nginx on windows.
I installed and i run successfully nginx with localhost example page.
After, under c:/nginx/html i created a subdirectory /hello/, with index.html in which the content is:
C:/nginx/html/hello/index.html
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Hello!</h1>
</body>
</html>
After, in the nginx.conf file, under http, i added the following:
server {
listen 80;
server_name www.localhello.com;
root C:/nginx/html/hello;
index index.html;
}
I added www.localhello.com also in my hosts file.
When I try to quit and restart nginx, and when i type www.localhello.com in my browser appears always the content of localhost (the content of C:/nginx/html/index.html preinstalled file) and i'm not able to understand why happen this.
I removed the peripheral "C:"
Now with this configuration works:
server {
listen *:80;
server_name www.localhello.com;
root /nginx/html/hello;
index index.html;
}

CSS3 PIE not showing rounded corners in IE8 mode within IE11

I'm not getting rounded corners in IE8 mode within IE11.
I've tried both relative and absolute paths, and neither work.
The PIE.htc file is in the same folder as the html file. I'm running on Jetty and don't have a .htaccess file. The PIE.htc file can be loaded without any problem using http://localhost:8383/various_forms2_less/PIE.htc
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<style>
span.command_link_buttoned {
background-color: #96AFCF;
display: block;
width: 130px;
height:30px;
position:relative;
border-radius: 5px;
behavior: url(PIE.htc);
/*behavior: url(http://localhost:8383/various_forms2_less/PIE.htc);*/
}
</style>
</head>
<body>
<span class="command_link_buttoned">
Button
</span>
</body>
</html>

Heroku maintenance URL does not redirect

For test purposes, i have added the url http://google.com as the maintenance URL in heroku. When I turn the maintenance mode on and try to access my page, I get an ugly response instead of being redirected to google. Anyone else has that problem or do I not get something?
btw: the redirection to the error URL works just fine.
This is what I get as a response:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<style type="text/css">
html, body, iframe { margin: 0; padding: 0; height: 100%; }
iframe { display: block; width: 100%; border: none; }
</style>
<title>Offline for Maintenance</title></head>
</head>
<body>
<iframe src="http://google.com">
<p>Application Error</p>
</iframe>
</body>
</html>
This is the expected behavior, according to the Heroku support. They do not perform a redirect, but just include the page as an iframe into their own HTML file.
Too bad, that does not work so well if you host an API on Heroku that returns the responses in JSON or so.

Is there a better way to handle font_face (google fonts) than this?

In trying to get google fonts (font_face) working with IE7, 8, 9, Chrome and Firefox I ended up with a bit of a convoluted mess of files stored locally, on a remote server, as ttf, eot and woff. Is there a better/easier way to get them working for all these browsers? This is what I ended up doing to get it to work.
This is the html
<link href="Untitled_1.css" rel="stylesheet" type="text/css" />
<!--[if gte IE 7]>
<link rel="stylesheet" type="text/css" href="Untitled_1_ie.css" />
<![endif]-->
This is the first css (untitled_1.css):
#font-face {
font-family: 'Bangers';
font-style: normal;
font-weight: normal;
src: local('Bangers'), local('Bangers-Regular'), url('http://themes.googleusercontent.com/static/fonts/bangers/v4/DqeGA7eaz0hhOYTfkeJBIA.woff') format('woff');
src: url('Bangers.ttf'); /* for chrome/webkit */
}
This is the second (untitled_1_ie.css):
#font-face {
font-family: 'Bangers';
font-style: normal;
font-weight: normal;
src: url('Bangers.eot'); /* ie9 */
src: url('Bangers.eot?#iefix') format('embedded-opentype'); /* IE6-IE8 */
}
IE9 would only work with a locally stored version of the eot (or ttf) due to 'no cross-domain custom fonts' error, IE7/8 would only work with eot and Chrome would not work with woff (the default produced by google fonts website).
Thanks.

I am not able to change the URL in css file; by using mod_rewrite in apache

The URL is in bold letters where I want to make change...
It should be rewritten to url /csmmail/lib/webmail/folderTree.gif
Following is the html snippet...
<link href="/csmmail/lib/webmail/folderTree.css?v=bfb38b233d72ba6a690a39394d7c964f" type="text/css" rel="stylesheet">
x_2az UL, x_2az LI {
list-style-type: none;
margin: 0px;
white-space: nowrap;
}
x_2az UL {
padding: 0px 0px 0px 16px;
}
x_2az LI {
padding: 1px 0px 1px 0px;
}
x_2az IMG {
vertical-align: middle;
}
.x_2le {
margin-right: 3px;
}
.x_2bq {
vertical-align: bottom;
margin-left: 0px;
}
.x_2lf {
background: ***url(/lib/webmail/folderTree.gif***) no-repeat;
padding: 2px 0 3px 16px;
}
sprite_folder {
}
I am new to mod_rewrite;
I have tried by using in per directory conf file.
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{HTTP_REFERER} \.(css)$
RewriteRule ^/lib/webmail/folderTree\.gif$ /csmmail/lib/webmail/folderTree.gif [NC]
I think you're doing it wrong, just do :
RewriteRule ^/lib/webmail/folderTree\.gif$ /csmmail/lib/webmail/folderTree.gif
You can't really rely on HTTP_REFERER since all browser does not set it.
You are expecting the HTTP_REFERRER to match your .css file.
I guess you are expecting this because you have reference the image in your css file? This is an incorrect assumption.
The referrer will always be the actual page that was loaded in your browser, not the css page.
You can confirm this by using a HTTP sniffing tool like fiddler - http://www.fiddler2.com/fiddler2/
Try dropping the rewrite condition to see if that works.

Resources