briancray / PHP-URL-Shortener

577 stars 216 forks source link

Adapt for NGINX #21

Open SteffeyDev opened 8 years ago

SteffeyDev commented 8 years ago

Its not that difficult to figure out, but it would be awesome if the README described how this works with NGINX as well. Basically all you need to do is put these lines in your site's file in /etc/nginx/sites-enabled:

autoindex off; location /shorten { rewrite ^/shorten/(.*)$ /location/of/shorten.php?longurl=$1 break; }

location / {

there should be things in this block already, such as try_files

rewrite "^/([0-9a-zA-Z]{1,6})$" /location/of/redirect.php?url=$1 last;

}

And then assuming php works correctly, that should be it (after mysql is set up)