Showing posts with label Apache Web Server. Show all posts
Showing posts with label Apache Web Server. Show all posts

Thursday, September 17, 2020

Using apache mod_rewrite to redirect everything except selected folders

We can use setup Apache Web server's mod_rewrite to redirect everything except selected directories.

Let's consider two scenarios. 

  1. Whole site redirection. Let's assume we want to redirect http://www.mydomain.com to https://secure.mydomaintoo.com, however, except directories upload1 and upload2, we place a .htaccess file at the root directory of the system, e.g., /var/www/html,
    
    RewriteEngine On
     RewriteCond %{REQUEST_URI} !^/upload1/.*
     RewriteCond %{REQUEST_URI} !^/upload1$
     RewriteCond %{REQUEST_URI} !^/upload2/.*
     RewriteCond %{REQUEST_URI} !^/upload2$
     RewriteRule ^(.*)$ https://secure.mydomaintoo.com/$1 [R=301,L]
    
  2. Subsite redirection. Let's assume we want to redirect http://www.mydomain.com/~subsite/ to https://secure.mydomaintoo.com, however, except directories upload1 and upload2, we place a .htaccess file at the root directory of the system, e.g., /var/www/html,
    
    RewriteEngine On
     RewriteCond %{REQUEST_URI} !^/~subsite/upload1/.*
     RewriteCond %{REQUEST_URI} !^/~subsite/upload1$
     RewriteCond %{REQUEST_URI} !^/~subsite/upload2/.*
     RewriteCond %{REQUEST_URI} !^/~subsite/upload2$
     RewriteRule ^(.*)$ https://secure.mydomaintoo.com/$1 [R=301,L]
    
    

Thursday, January 30, 2014

Web Server Video Support

I was playing with HTML 5 video and encountered the following error in Firefox "no video with supported format and MIME type found" and  that in Internet Explorer "Error: Unsupported video type or invalid file path". The HTML file looks like the following,


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>HTML 5 Video Example</title>
</head>
<body>
<h1>Chapter 1: HTML/XHTML</h1>
<h2>Video Example</h2>
<video width="600" height="500"
       autoplay="autoplay"
       controls="controls"
       preload="auto"
       poster="novideo.png">
  <source src="./ex.mp4" type="video/mp4" />
  <source src="./ex.ogv" type="video/ogg" />
  <source src="./ex.webm" type="video/webm" />
  Your browser does not support the video element
</video>
</body>
</html>

The video clip of all 3 formats are at the server and the video plays well at the local machine and fine at another server. After a little bit digging, I found out that the Apache web server has some configuration issue and did not have proper MIME types added. To fix it, simply upload a .htaccess file to the directory where the HTML file is and the .htaccess has the following content,


AddType video/webm .webm
AddType video/mp4 .mp4
AddType video/ogg .ogv