Multi Domain Support #560

Closed
ozh opened this Issue Apr 6, 2013 · 5 comments

Projects

None yet

5 participants

@ozh
Member
ozh commented Apr 6, 2013

This is a COPY of Issue 560: Multi Domain Support, filed on Google Code before the project was moved on Github.

Please review the original issue and especially its comments. Comments here on closed issues will be ignored. Thanks.

Original description

I think it would be amazing if Yourls offered support for multiple domains for instance a user who signs up could use a default short url like   my.ly or they could use their own domain like them.ly this is one of the most amazing features that bit.ly currently offers is support for using your own domain instead of bit.ly and if people could simply come to my site and signup and use their own domain god that would rock because open source YOURLS would rock bit.ly and I would stop using bit.ly all together.




**Any idea on how it could be implemented? (interface, code, whatever)**
I imagine that it could be setup so that a user creates a cname record to the main Yourls default short name and then it begins working.... im sure it would require a lot of backend work.... :)
@ozh ozh closed this Apr 6, 2013
@DonKingMat

You have multiple domains and want to link all your domains to ONE YOURLS installation.
You want to enable your http://nice.name and your http://also-nice-but-long.nice.name to the same YOURLS DB without editing each yourls entry twice (or more ...).

Your webservers config file should configured simliar like this:

 ServerName *.nice.name
 DocumentRoot /var/www/html/nice
 ...
 <Directory "/var/www/html/nice">
  Options Includes Indexes

or

 ServerName nice.name
 ServerAlias also-nice-but-long.nice.name
 DocumentRoot /var/www/html/nice
 ...
 <Directory "/var/www/html/nice">
  Options Includes Indexes
 ...

Copy all ("YOURLS"-related) files and folders to a new created /var/www/html/longnice path (precreation of longnice folder not necessary and no slashes at the end!!):

cp -r /var/www/html/nice /var/www/html/longnice

Copy your webservers config file to be responsive to both URLs in each seperate config file similar like this:

cp /etc/httpd/conf.d/mysite-nice.conf /etc/httpd/conf.d/mysite-longnice.conf

Configure your both config files (in comparison to example at the top) similar like this:

 ServerName nice.name
 DocumentRoot /var/www/html/nice
 ...
 <Directory "/var/www/html/nice">
  Options Includes Indexes
 ...

and

 ServerName also-nice-but-long.nice.name
 DocumentRoot /var/www/html/longnice
 ...
 <Directory "/var/www/html/longnice">
  Options FollowSymLinks Includes Indexes
 ...

Now refine your /var/www/html/longnice/user/config.php YOURLS dedicated config file and change entry
define( 'YOURLS_SITE', 'http://nice.name' );
to
define( 'YOURLS_SITE', 'http://also-nice-but-long.nice.name' );

Restart your webservers config changes

service httpd configtest <-- check misstyping or any other strange things
service httpd reload (or restart)

That's it. Repeat it as many times you want to and as many URLs you like.


Why do I bring in the FollowSymLinks into longnice's config? In my example at the top both URLs point to one DocumentRoot and I explain to copy all DocumentRoot's content. What if you not only have YOURLS online at your nice.name domain? Some of you also will have your private life or your business at the same domain. Copy whole content is not the best idea. It eats storage and it's not easy to maintain all folders twice so one eays way could be to:

Delete all folders are not related to YOURLS in the new /var/www/html/longnice (admin, css, images, includes, js, pages, user) and symlink those folders to previous folders at /var/www/html/nice/whatever

ln -s /var/www/html/nice/whatever /var/www/html/longnice/whatever
ln -s /var/www/html/nice/whatelse /var/www/html/longnice/whatelse
...

There are many more ways to fit your needs. I just want to show the concept of a way to do it. I am sure you understand it principally.

Do not forget to google about the risk of "FollowSymLinks" in your webservers config!

Greets ... G-Nick

@ozh
Member
ozh commented Jun 19, 2014

Awesome guide, thanks for this. I'll link to this in the wiki for anyone interested.

@nphunghung

Some script allows user selected Multi short url domain as "Short URL Script v3.3" after enter the domain into input. Can YOURLS make it so simplify instead of having to do such complex?

@LeoColomb
Member

Can YOURLS make it so simplify instead of having to do such complex?

It will come in future version, yes 🏇

@toleabivol

Hi , thanks for great tool.
Is this feature still in the roadmap ?
Keeping one install/docroot per domain only with a change in config seems not good practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment