1

My main domain is smile.ws I have installed yourls in smile.ws/yourls.

As a result, all my shortened urls are smile.ws/yourls/link instead of smile.ws/link

I followed the wiki instructions but that didn’t help.

I looked around and found a plugin called "Swap Short Url" which is supposed to help in these situations. It has slightly different .htaccess recommendation. I followed the instructions correctly and it works, because now the urls are smile.ws/link. But when you click on them, you get a 404 error.

How can I fix this? Thanks!



PS I know this is not a programming question. However, Stackoverflow has a tag for YoURLS that has 55 questions.
big_smile
  • 1,487
  • 4
  • 26
  • 59

2 Answers2

1

This to me sounds like it is related to the web servers .htaccess file but I can't be certain unless you can give us an example. I have a YOURLS site that work as you are describing without using a plugin. This really comes down to how the web server is configured and the YOURLS settings. Here is a sample of my .htaccess file.

# BEGIN YOURLS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /yourls-loader.php [L]
</IfModule>
# END YOURLS

In your config file this line needs to look like this.

define( 'YOURLS_SITE', 'http://smile.ws' );

If this doesn't work it might be due to your web server not having the correct permissions set or the rewrite module not enabled assuming you are using apache.

  • I changed my Htaccess to exactly like your example, but it doesn't work. I also used your config example. Some questions 1. This is the .htaccess file that is in the yourls subdirectory? 2. Does the config file text go at the end of the config file? 3. Once I've made the changes, do I need to do anything to Yourls to make it 'see' the changes? 4. I am using Cpanel/LunarPages shared hosting and installed yourls via Softaculous app installer. Does that make a difference? – big_smile Nov 23 '19 at 12:32
  • 1
    The .htaccess file should be in the subdirectory of your last. That config line should already exist and you should just need to replace it. You shouldn’t have to do anything for the changes but it never hurts to restart your web server. I personally have never used any hosting service so I am unsure how that would affect it if at all. When I have done my installations they have been on compute VM’s – Darrell Agee Nov 24 '19 at 18:17
  • @big_smile Did you ever resolve your issues, I'm currently experiencing the exact same issue. Thanks. – jtvdw Feb 02 '21 at 22:09
  • I am as well. Any help would be appreciated. I have my server with yourls behind a reverse proxy that passes URLs to http://server.TLD/YOURLS/etc, while it is at https://links.mydomain.TLD/etc – Cliff Hill Jul 20 '21 at 02:17
0

Did anyone check the root .htaccess?

# BEGIN YOURLS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /YOURLS/yourls-loader.php [L]
</IfModule>
# END YOURLS

This line needs to set the subdirectory /your dir here/

RewriteRule ^.*$ /YOURLS/yourls-loader.php [L]
Mitch
  • 37
  • 8