Creating links but avoiding creating a folder on the server for each link

I want to allow auto generation of links such as mydomain.com/link_reference to bring up specific information about when shared with other people.

I’ve previously implemented a script that auto generated a link such as mydomain.com/link_reference

I achieved this using the mkdir and copy commands in PHP. The created folder; ‘link_reference’ contained only index.php which obtained the ‘link_reference’ value out of the browser address variable in javascript and used it to display various information pertaining to the ‘link_reference.’

I’m wondering if there is a better way of achieving this, without creating a new folder each time. I’m using the Google App Engine, and so I’m thinking that the app.yaml file might be useful for this.

The YAML is:

application: my_app****
version: 1
module: default
runtime: php55
api_version: 1

handlers:  
# Serve images as static resources.
- url: /(.+.(gif|png|jpg))$
  static_files: 
  upload: .+.(gif|png|jpg)$
  application_readable: true

- url: /javascript
  static_dir: javascript
  mime_type: text/html
  application_readable: true

# Serve php scripts.
- url: /(.+.php)$
  script: 

# Go to index.php when domain entered
- url: /
  script: index.php


# Go to get_reference.php when link_reference detected
- url: /***some kind of matching expression
  script: get_reference.php

Presently, the auto generated reference is 8 characters, uppercase letters or integers only. E.g.: GLS8L4RS

I’m not sure how to set up a regex matching expression, and I’m not sure if this is even the best practice implementation of a solution.


Source: regex

Leave a Reply