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

Incompatibility with "Allow Hyphens in Short URLs" #10

Open
18hv opened this issue Sep 19, 2016 · 7 comments
Open

Incompatibility with "Allow Hyphens in Short URLs" #10

18hv opened this issue Sep 19, 2016 · 7 comments

Comments

@18hv
Copy link

18hv commented Sep 19, 2016

The plugin works very well but it appears incompatible with the "Allow Hyphens in Short URLs" plugin. With both plugins activated, a hyphened URL returns a page not found error; while non-hyphened URLs still work fine.
Is it possible to modify and work with hyphened URLs?

@jslching
Copy link

Modify the .htaccess in the instructions to have "[-0-9A-Za-z]+" instead of "[0-9A-Za-z]+"

@18hv
Copy link
Author

18hv commented Oct 17, 2018

Thanks, where specifically do I make this change, there is no similar data in .htaccess (in the Yourls root directory)?

@jslching
Copy link

jslching commented Oct 17, 2018

You need to direct traffic from your defined short url to your yourls installation. To do this, create (or modify) an .htaccess file in the directory you defined as your YOURLS_SHORT_URL with the following:

RewriteEngine On
RewriteBase /

# BEGIN YOURLS

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([0-9A-Za-z]+)/?$ http://shorturl.com/yourls/yourls-go.php?id=$1 [L]
RewriteRule ^([0-9A-Za-z]+)\+/?$ http://shorturl.com/yourls/yourls-infos.php?id=$1 [L]
RewriteRule ^([0-9A-Za-z]+)\+all/?$ http://shorturl.com/yourls/yourls-infos.php?id=$1&all=1 [L]

# END YOURLS

In the RewriteRules above, change the prefix to ^([-0-9A-Za-z]+), instead of ^([0-9A-Za-z]+)

@jslching
Copy link

I made an edit to the comment above, the hyphen should go inside the square brackets.

@jslching
Copy link

It is also sufficient to replace the three RewriteRules with just one:

RewriteRule ^([-0-9A-Za-z]+(\+(all)?)?\~?)/?$ http://shorturl.com/yourls/$1 [L]

@18hv
Copy link
Author

18hv commented Oct 22, 2018

I have tried all recommendations and various options, and still a hyphen in the shortened URL does not work. There must be something else in my configuration stopping it?

@Dominik55555
Copy link

It works when I changed the prefix to ^ ([- 0-9A-Za-z] +),
in every rule

Thank You jslching

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