Skip to content
Snippets Groups Projects
Commit cf9b4292 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

update docs

parent 367c99c2
No related branches found
No related tags found
No related merge requests found
# Features #
* handle Redirects with strings or regex
* one config file per handled domain
* aliases can be defined to handle same redirects
* optional debugging (will be written into http reponse header)
* admin to list and filter all existing domains and redirects
# Configuration #
In the config folder are json files. Copy the dist files to the same filename without ".dist"
* redirects_[FQDN].json
* aliases.json
## Redirects ##
There are 2 required sections to define redirects:
* direct
* regex
The section "direct" will be scanned first and has priority.
The json will be read into a hash ... if you define a direct rule twice then
the last rule will win.
If no direct rule matches the regex section will be scanned. Winner is the
first matching regex.
If no rule matches a 404 will be shown.
Hint: if you set regex ".*" as last entry it works as a catchall for unmatched
requests and you can define a default redirect target instead of showing a 404.
Both redirect section contain a redirect definition
* code - http status code for redirection
* target - target url of the redirect
Status codes
* 301 => 'Moved Permanently'; the url is outdated
* 307 => 'Temporary Redirect'; the url is valid
* 308 => 'Permanent Redirect'; the url is outdated
Suggestion for redirection lifecycle:
* an active redirect (i.e. a campaign) use code 307
* if the redirect has finished its life, switch the code to 308 or 301.
* remove the redirect (which results into 404)
Example:
```json
{
"direct":{
"heise": {"code": 307, "target": "https://www.heise.de" }
},
"regex":{
"^$": {"code": 307, "target": "https://www.iml.unibe.ch" },
"^ax.l.*": {"code": 307, "target": "https://www.axel-hahn.de" }
}
}
```
## Server aliases ##
If you have multiple domains with the same rules you can define aliases.
Example:
```json
{
"www.example.com": "example.com",
"zzz-domainname": "existing-host-with-redirect-config"
}
```
The key is the name of the alias. The value is a domain for that was written a
redirect_[hostname].json already.
The existance of a redirect config has higher priority than an entry in the
aliases config.
# Installation #
Extract archive 1 level above webroot. The document root of the web must point
to the public_html directory. The config folder is outside the webroot.
Redirect all requests to the index.php. Activate the .htaccess or (better)
add the config of the htaccess file to the vhost config.
```text
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /index.php [L]
```
In the DNS point all hostnames with redirects only to this server (i.e. with
a CNAME).
If you don't have a single vhost in the webserver then additionally add the
domains to "catch" as ServerAlias.
......@@ -11,111 +11,3 @@ License: GNUP GPL 3.0
* PHP 7+
* Webserver (docs describe usage for Apache httpd)
## Installation ##
Extract archive 1 level above webroot. The document root of the web must point
to the public_html directory. The config folder is outside the webroot.
Redirect all requests to the index.php. Activate the .htaccess or (better)
add the config of the htaccess file to the vhost config.
```text
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /index.php [L]
```
In the DNS point all hostnames with redirects only to this server (i.e. with
a CNAME).
If you don't have a single vhost in the webserver then additionally add the
domains to "catch" as ServerAlias.
## Configuration ##
In the config folder are json files. Copy the dist files to the same filename without ".dist"
* redirects_[FQDN].json
* aliases.json
### Redirects ###
There are 2 required sections to define redirects:
* direct
* regex
The section "direct" will be scanned first and has priority.
The json will be read into a hash ... if you define a direct rule twice then
the last rule will win.
If no direct rule matches the regex section will be scanned. Winner is the
first matching regex.
If no rule matches a 404 will be shown.
Hint: if you set regex ".*" as last entry it works as a catchall for unmatched
requests and you can define a default redirect target instead of showing a 404.
Both redirect section contain a redirect definition
* code - http status code for redirection
* target - target url of the redirect
Status codes
* 301 => 'Moved Permanently'; the url is outdated
* 307 => 'Temporary Redirect'; the url is valid
* 308 => 'Permanent Redirect'; the url is outdated
Suggestion for redirection lifecycle:
* an active redirect (i.e. a campaign) use code 307
* if the redirect has finished its life, switch the code to 308 or 301.
* remove the redirect (which results into 404)
Example:
```json
{
"direct":{
"heise": {"code": 307, "target": "https://www.heise.de" }
},
"regex":{
"^$": {"code": 307, "target": "https://www.iml.unibe.ch" },
"^ax.l.*": {"code": 307, "target": "https://www.axel-hahn.de" }
}
}
```
### Server aliases ###
If you have multiple domains with the same rules you can define aliases.
Example:
```json
{
"www.example.com": "example.com",
"zzz-domainname": "existing-host-with-redirect-config"
}
```
The key is the name of the alias. The value is a domain for that was written a
redirect_[hostname].json already.
The existance of a redirect config has higher priority than an entry in the
aliases config.
## Ideas ##
The current functionality is available with rewrite rules. Maybe in future
one of these features could be implmeneted:
* track request before redirecting to generate a statistic
* lifecycle of campaign short urls
* admin interface / just a viewer for all definitions
{
"title": "IML Redirect",
"author": "Axel Hahn",
"tagline": "Redirect urls of any domain that points here.",
"ignore": {
"files": ["30_PHP-client/Plugins/Checks/_skeleton.md"],
"folders": ["99_Not_Ready"]
},
"html": {
"auto_toc": true,
"auto_landing": false,
"date_modified": false,
"jump_buttons": true,
"edit_on_github_": "iml-it/appmonitor/tree/master/docs",
"links": {
"Git Repo": "https://git-repo.iml.unibe.ch/iml-open-source/redirect-handler/"
},
"theme": "daux-blue",
"search": true
}
}
\ No newline at end of file
/*
patch css elements of daux.io blue theme
*/
/* ---------- vars ---------- */
:root{
/* background colors */
--bg:none;
--bg-body: #fff;
--bg-navlinkactive:#f4f4f4;
--bg-navlinkactive: linear-gradient(-90deg,rgba(0,0,0,0), rgba(40,60,80,0.05) 30%);
--bg-pre:#f8f8f8;
--bg-toc: #fff;
/* foreground colors */
--color: #234;
--navlinkactive:#f33;
--title: #aaa;
--link:#12a;
--toclink:rgba(40,60,80,0.8);
--h1: rgba(40,60,80,0.8);
--h1-bottom: 1px solid rgba(40,60,80,0.1);
--h2: rgba(40,60,80,0.5);
--h3: rgba(40,60,80,0.3);
}
/* ---------- tags ---------- */
body, *{color: var(--color); }
body{background: var(--bg-body);}
a{color: var(--link);}
a:hover{opacity: 0.7;}
h1>a{ color:var(--title);}
_h1:nth-child(1){position: fixed; background: var(--bg); box-shadow: 0 0 1em #ccc; padding: 0 1em}
h1:nth-child(1)>a{ color:var(--navlinkactive); }
.s-content h1{color: var(--h1); font-size: 200%; font-weight:bold; margin-top: 2em; border-bottom: var(--h1-bottom);}
.s-content h2{color: var(--h2); font-size: 160%; }
.s-content h3{color: var(--h3); font-size: 140%; }
.s-content h4{margin: 0; font-size: 100%; text-align: center; background-color: rgba(0,0,0,0.05);padding: 0.3em;}
.s-content pre{
background: var(--bg-pre);
}
/* ---------- classes ---------- */
.required{color:#a42;}
.optional{color:#888;}
/* ----- top left */
.Brand,
.Columns__left {
background: var(--bg);
border-right: 0px solid #e7e7e9;
color: var(--color);
}
.Brand{font-size: 200%;
background_: linear-gradient(-10deg,#fff 50%, #ddd);
background: var(--bg);
}
.Columns__right__content {
background: var(--bg);
}
/* ----- Navi left */
.Nav a:hover{
background: none;
color: var(--navlinkactive) !important;
}
.Nav__item--active {
border-right_: 0.3em solid var(--navlinkactive);
}
.Nav__item--active > a{
background: var(--bg-navlinkactive);
color: var(--navlinkactive);
}
.Nav .Nav .Nav__item--active a {
color: var(--navlinkactive);
}
.Nav .Nav .Nav__item a {
opacity: 1;
}
.Nav__item--open > a {
background-color: var(--bg);
}
.Nav a[href*="__Welcome"]{
background: url("/icons/house.png") no-repeat 10px 4px ;
padding-left: 40px;
}
.Nav a[href*="__How_does_it_work"]{
background: url("/icons/light-bulb.png") no-repeat 10px 4px ;
padding-left: 40px;
}
/* ---------- classes ---------- */
/* FIX smaller fnt size in tables */
.s-content table {
font-size: 1em;
}
/* TOC */
@media(min-width:1700px){
.TableOfContentsContainer{
position: fixed;
right: 2em;
top: 1em;
}
}
.TableOfContentsContainer{
border-top-left-radius: 1em;
background-color: var(--bg-toc);
border-left: 2px solid rgba(0,0,0,0.05);
padding: 0em;
}
.TableOfContentsContainer__content {
border: none;
font-size: 0.5em;
}
ul.TableOfContents ul{
list-style-type: none;
padding-left: 1em;
}
.TableOfContentsContainer a{ color:var(--toclink);}
.TableOfContentsContainer__content > .TableOfContents > li + li {
border-top: none;
}
.TableOfContentsContainer__content > .TableOfContents > li {
border-bottom: 1px dashed #ddd;
}
/* pager - prev .. next */
.s-content{
margin-bottom: 6em;
}
.Pager{
border-top: 1px dashed #aaa; margin: 0; padding: 1em;
}
.Pager a{
color:var(--navlinkactive);
}
......@@ -7,4 +7,4 @@ Author: Axel Hahn; Institute for Medical Education; University of Bern
License: GNUP GPL 3.0
see [docs](./docs)
See the [docs](./docs)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment