Use one instance of Yourls URL shortner with multiple domains

keisar

I've been looking for a way to use Yourls with multiple domains, the main issue is that when configuring Yourls you need to supply the domain name in the config.php file (YOURLS_SITE constant). Configuring just one domain with actual multiple domains pointing to Yourls causes unexpected behavior.

I've looked around and couldn't find a quick hack for this

keisar

I found this quick-and-dirty solution and thought it might be useful for someone.

in the config.php file I changed the constant definition to be based on the value of $_SERVER['HTTP_HOST'], this works for me because I have a proxy before the server that sets this header, you can also define virtual hosts on your Apache server and it should work the same (perhaps you will need to use $_SERVER['SERVER_NAME'] instead).

so in config.php I changed:

define( 'YOURLS_SITE', 'http://domain1.com');

to

if (strpos($_SERVER['HTTP_HOST'],'domain2.com') !== false) {
        define( 'YOURLS_SITE', 'http://domain2.com/YourlsDir');

        /* domain2 doesn't use HTTPS */
        $_SERVER['HTTPS']='off';

} else {
        define( 'YOURLS_SITE', 'https://domain1/YourlsDir');

        /* domain1 always uses HTTPS */
        $_SERVER['HTTPS']='on';

}

Note1: if Yourls is located in the html root you can remove /YourlsDir from the URL Note2: The url in YOURLS_SITE must not end with /

Hopefully this will help anyone else

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Nginx restrict domains

来自分类Dev

Multiple synchronous streams in one Gulp task?

来自分类Dev

Multiple Selects into one select

来自分类Dev

declare Struct in Header and use in multiple Sources

来自分类Dev

Clojure, concat multiple sequences into one

来自分类Dev

Sharing session across multiple domains on same server in PHP

来自分类Dev

Left join multiple tables onto one table

来自分类Dev

Java: Copy attributes from one object instance to another?

来自分类Dev

How to undo strsplit to put multiple characters into one

来自分类Dev

.htaccess URL为Yourls重写失败-在此服务器上找不到请求的URL

来自分类Dev

Join multiple records to one row?

来自分类Dev

Multiple Summer note divs on one page

来自分类Dev

Use Octave/Matlab combine multiple blobs in close proximity into one blob

来自分类Dev

what object type/instance to use for synchronization

来自分类Dev

How can I use a type synonym in an instance declaration?

来自分类Dev

Find matching type for one of multiple joined tables

来自分类Dev

带有Google Domains URL的Heroku网站未在Android KitKat上加载

来自分类Dev

Ember Model with only One Instance

来自分类Dev

将Yourls URL缩写的一个实例与多个域一起使用

来自分类Dev

Check multiple checkboxes with one global funtion

来自分类Dev

How to write multiple statements in one if block in clojure?

来自分类Dev

sed to replace multiple words but skip one

来自分类Dev

How to configure a single flask application to handle multiple domains?

来自分类Dev

如何正确使用UrlFetchApp.fetch的Google URL Shortner API?

来自分类Dev

Jquery - Multiple function calls to one AJAX call

来自分类Dev

YOURLS插件可过滤特定MySQL列的API调用

来自分类Dev

Connecting multiple Curator to a single Zookeeper instance?

来自分类Dev

Opposite of tidyr::separate, concatenating multiple columns into one

来自分类Dev

Is there a way to tell the servlet container to spawn one instance of a resource at a time?

Related 相关文章

  1. 1

    Nginx restrict domains

  2. 2

    Multiple synchronous streams in one Gulp task?

  3. 3

    Multiple Selects into one select

  4. 4

    declare Struct in Header and use in multiple Sources

  5. 5

    Clojure, concat multiple sequences into one

  6. 6

    Sharing session across multiple domains on same server in PHP

  7. 7

    Left join multiple tables onto one table

  8. 8

    Java: Copy attributes from one object instance to another?

  9. 9

    How to undo strsplit to put multiple characters into one

  10. 10

    .htaccess URL为Yourls重写失败-在此服务器上找不到请求的URL

  11. 11

    Join multiple records to one row?

  12. 12

    Multiple Summer note divs on one page

  13. 13

    Use Octave/Matlab combine multiple blobs in close proximity into one blob

  14. 14

    what object type/instance to use for synchronization

  15. 15

    How can I use a type synonym in an instance declaration?

  16. 16

    Find matching type for one of multiple joined tables

  17. 17

    带有Google Domains URL的Heroku网站未在Android KitKat上加载

  18. 18

    Ember Model with only One Instance

  19. 19

    将Yourls URL缩写的一个实例与多个域一起使用

  20. 20

    Check multiple checkboxes with one global funtion

  21. 21

    How to write multiple statements in one if block in clojure?

  22. 22

    sed to replace multiple words but skip one

  23. 23

    How to configure a single flask application to handle multiple domains?

  24. 24

    如何正确使用UrlFetchApp.fetch的Google URL Shortner API?

  25. 25

    Jquery - Multiple function calls to one AJAX call

  26. 26

    YOURLS插件可过滤特定MySQL列的API调用

  27. 27

    Connecting multiple Curator to a single Zookeeper instance?

  28. 28

    Opposite of tidyr::separate, concatenating multiple columns into one

  29. 29

    Is there a way to tell the servlet container to spawn one instance of a resource at a time?

热门标签

归档