A small PHP script that redirects to a URL based on a keyword matched against a CSV sheet on a URL.
-
Place files in an NGINX webserver with PHP support
-
Update path to CSV file (
$csv
variable)
Since NGINX does not read .htaccess
you must add a redirect into the config. (This is done for you when deploying with this Ansible playbook)
To do so add rewrite ^/(.*)$ /index.php?link=$1 last;
at the last line of the location / {
block. For example:
location / {
try_files $uri $uri/ =404;
rewrite ^/(.*)$ /redir.php?link=$1 last;
}
Line in CSV file:
keyword
,destination_url
For example:
example
,https://example.org
Browse to:
https://
link.hypha.coop
/keyword
For tips on managing and using these shortlinks, see the Shortlink Guides in Hypha's Handbook.
We use this Ansible playbook to configure our reverse proxy and web server vhosts which also creates the directory to store the site files.
Once the playbook is done we can now deploy the site files using Travis CI with the deploy
user's SSH key.
staging
branch deploys to the staging server accessible here: https://link.staging.hypha.coop
master
branch deploys to the production site.