Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 when going onto shortened URLs #9

Open
Shoot opened this issue Aug 16, 2018 · 5 comments
Open

404 when going onto shortened URLs #9

Shoot opened this issue Aug 16, 2018 · 5 comments

Comments

@Shoot
Copy link

Shoot commented Aug 16, 2018

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.

@lfdelphino
Copy link

Hey @old , I was experiencing the same issue and I could fix it.

There are a few things that may be causing it, first of all, are you trying to use a different URL to shorten your links or the default index.php? If it's the default shouldn't be a problem.

Second, make sure that you run the following SQL command on your MySQL or MariaDB:
CREATE TABLE urls ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, url VARCHAR(1000) NOT NULL, created DATETIME NOT NULL, accessed DATETIME, hits INT UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE (url) );

I was using a different SQL code that I found by mistake and also my goal was to be able to shorten the URL at a different location, to do so you would only have to change on .htaccess from:
RewriteRule ^(.*)$ index.php?q=$1 [QSA,L]
to (change the NEW_URL):
RewriteRule ^(.*)$ https://%{HTTP_HOST}/NEW_URL.php?q=$1 [QSA,L]

Hope it works!

@Nottt
Copy link

Nottt commented Jul 31, 2019

I'm having the same issue, but the above solution didn't help me! Running the sql command just says:

ERROR 1050 (42S01): Table 'urls' already exists

@lfdelphino
Copy link

First remove your table urls, then run the above SQL please

@Nottt
Copy link

Nottt commented Jul 31, 2019

My website domain is subdomain.domain.com, and I'm generating subdomain.domain.com/link/XXX o i still need to use your SQL command?

I'm a bit lost here, ideally I'd like to use another domain, a shorter one in the generated links... like xx..cc which I own, I'm just using that for testing...

Do I need to have my xx.cc domain pointed to the same IP address as my subdomain.domain.com? Do I need to change something in apache?

My shorty files are in /var/www/html/link so that's why i went with that for testing...

@Nottt
Copy link

Nottt commented Jul 31, 2019

ok, so my issue seems that going to xx.cc redirects to subdomain.domain.com/XXX and this doesn't work but subdomain.domain.com/link/XXX works.

How to fix this?

Edit:

I fixed this with a cloudflare rule, I now forward xx.cc/* to subdomain.domain.com/link/ so it works. I'm doing 2 redirects to get to the shortened link but at least works.

A solution which only does 1 redirect locally would be better/faster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants