mikecao / shorty Goto Github PK
View Code? Open in Web Editor NEWA simple URL shortener for PHP
License: MIT License
A simple URL shortener for PHP
License: MIT License
I'm not sure if you maintain this anymore or if you would even be willing to help me with my issue. Regardless I'll ask.
I'm using PHP 7.4 on Ubuntu 20.04.4 using nginx to server my site.
To my knowledge I have configured everything correctly.
Upon testing it does display the shortened url page however it does not finish its execution, therefore the shortened url isn't actually attached to anything.
Checking my error log (/var/log/nginx/error.log) I see it has produced the following exception.
2022/06/27 23:57:33 [error] 739740#739740: *1953 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: q in /var/www/mysite.com/shorty.php on line 314" while reading response header from upstream, client: 172.69.68.17, server: mysite.com, request: "GET /index.php?url=http://www.google.com HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "mysite.com"
The issue stems from this line
While I do not think this is the cause of my issues it might be relevant.
The mysql user that shorty is using only has INSERT, SELECT, and UPDATE permissions within the scope of shorty.urls
When doing:
mysql -u root -p new_database < database.sql
I see the error:
ERROR 1071 (42000) at line 4: Specified key was too long; max key length is 767 bytes
using MariaDB.
This seems to be a limitation of the database itself, according to:
Would there be any way to work around this?
My last PR introduced a bug that does not allow new URLs to be created because q
is empty before that logic is processed. My next PR will fix this behavior.
The home page does not show a 404 message because $_GET['url']
is unset at the time of checking. The page is blank, and an error is logged:
2018/04/04 21:51:30 [error] 2990#2990: *21 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: url in /usr/share/nginx/html/v.craftblock.me/shorty.php on line 315
PHP message: PHP Notice: Undefined index: format in /usr/share/nginx/html/v.craftblock.me/shorty.php on line 316" while reading response header from upstream, client: 172.69.142.45, server: v.craftblock.me, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.2-fpm.sock:", host: "v.craftblock.me"
Set everything up following the guide, .htaccess, confs for the domain etc all done, database sorted. When I try to add a URL it generates, but when I click on the URL it doesn't work, instead giving a 404 message.
It works fine, I think.
But where are the IDs / the shorted URLs stored?
In the database is only an ID and the long URL but no shorted URL...
I always get this error when open my website
My .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [QSA,L]
config.php is finished too
I followed the guide, added database and htdocs.
But I still get this error.
Notice: Undefined index: q in C:\xampp\htdocs\shorty\shorty.php on line 314
404 Not Found
this is my project path : C:\xampp\htdocs\shorty
this is my htdocs path : C:\xampp\htdocs\shorty.htdocs
this is my config file.
<?php
// Hostname for your URL shortener
$hostname = 'http://localhost.com';
// PDO connection to the database
$connection = new PDO('mysql:dbname=shorty_temp;host=localhost', 'root', '');
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$salt = '';
$padding = 3;
?>
how can I fix this?
I think homepage in index.php and making custom link can be awesome for your script like https://bit.do
For example, always generate 6-chars key for id 1 to 1,000,000?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.