Redirect Apache Requests to Applications

When requests come into the Apache Web server, they are routed by default to the files in the Document Root. Sometimes we want to redirect those requests elsewhere. We can do this with the Rewrite module.

Add the Rewrite directives to the Apache config file, an .htaccess file, or do what I usually do and add it to the Virtual Host file.

Rewrite for SPAs

To direct requests to Single Page Web-apps, such as those that are build with React and Vue.js. This is what works for me.

<Directory "/var/www/my-app/dist">
Options Indexes FollowSymLinks
order allow,deny
allow from all

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /index.html [NC,L]

PHP Applications

Often when using Apache to host a PHP Web application, it’s desirable to handle incoming requests with PHP. By default, Apache will try to handle requests. But, we can use the rewrite module to send requests to specified PHP scripts.

<Directory "/path/to/webroot">
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?/$1 [L]

Maven – Compiling JAR with Dependencies

Although I’m familiar with Java, I don’t use it day-to-day. To keep current with arguably the worlds most popular programming language, I decided to use Java in a project that I’m working on in my off hours. In that project (which gathers and analyzes economic data) I decided to use Maven. Even-though my small project doesn’t necessitate the need for such a tool, Maven implements many industry best practices (or at least promises to do so). So, I figured that it would be worth while to learn to use it.
Continue reading

Time Clock and Windows Dual Boot

broken clock

Part of the standard way to handle time on computers is to set the hardware clock (a.k.a. the BIOS clock) to UTC. Then users can select a timezone for displaying as their system time. Contrary to this conventional way of doing things, the Windows operating system sets the hardware clock to the configured local time. Clock malfunctions tend to happen if you’re dual booting a Linux system. Posix operating systems expects the convention to be followed. Here’s how I addressed this problem.
Continue reading

Recording and Replaying GPS Data

The Arduino Uno
The Arduino Uno

In my last post on the Arduino Uno, I took my first steps with the microcontroller and started getting data from a GPS module – the Ublox NEO 6M. Once I was able to receive data from the module – which was pretty neat by itself if you think about it, I wanted to actually do something with the data. I thought a good next step would be recording data and playing it back while plotting it on a map.

Continue reading