The MU forums have moved to WordPress.org

installing in subdomain but pointing to main domain (25 posts)

  1. plusarquitectura
    Member
    Posted 17 years ago #

    Hello to everyone,

    I have installed WPMU in blogs.domain.tld because I don't want to mess files in domain.tld (installing in root domain is not an option)

    When new blogs are created they got this url pattern: username.blogs.domain.tld

    Is there any way to make the url look like this: username.domain.tld?

    Thank you in anticipation

    PS: I've been searching about this subject and I've found many people who asked the same question, but the only replies that I found were "this has been answered before" or "install it in main domain". Sorry if I didn't succeed in finding the right answer that can help to solve my problem.

  2. jaredbangs
    Member
    Posted 17 years ago #

    Have you looked into mod rewrite rules?

  3. plusarquitectura
    Member
    Posted 17 years ago #

    Jaredbangs, I took a look into my .htaccess file but I wasn't able to understand how it works, despite being quite short... Could you please give me a hand with it? I'm not good at all with programming stuff

    Thanks

  4. drmike
    Member
    Posted 17 years ago #

    Well, MU is designed to be install in the main domain. That is the answer. That's why you've found it.

    You can do it with redirects but considering you're already doing redirects within the software for the subdomains, that puts extra strain on the server and will probably get you ToS'ed from most hosts.

  5. jaredbangs
    Member
    Posted 17 years ago #

    I think the bottom line is that there are ways to do it, but none of them are pretty nor recommended.

    I don't know what kind of resources you have available to you, but if you've got a spare IP address on that server you could always install MU as domain.tld, handled by a second IP, and just use your local hosts file to point the machine you'll be doing the setup etc. on to that IP rather than the primary one, and keep the public facing DNS pointing domain.tld to the existing site that you can't change, and have *.domain.tld point to your MU installation.

    The obvious downside to that is that the "root" MU site won't be publicly available, so things like the normal sign-up process won't be available, which may or may not work for you.

  6. lunabyte
    Member
    Posted 17 years ago #

    If you're domain is domain.tld, and blogs are at blogs.domain.tld, and you want username.domain.tld, it isn't that difficult.

    No .htaccess editing.

    You'll need to install it on blogs.domain.tld.

    You'll need to add domain.tld to your wp_site table, then go through the sign-up process and anywhere it looks for $site_id, (which normally would be trying to insert it as 1) and if it is "1", then use an if clause to change it to 2 (which will be the main domain site id).

    Then, you'll need to modify the cookie to look and see if it's blogs.domain.tld, and if it is, set it for domain.tld instead. This is because it would try to set a sub-domain independent cookie for blogs.domain.tld so that username.blogs.domain.tld was as good as username2.blogs.domain.tld, but all your blogs will be on *.domain.tld.

    Yes it requires a few core edits (keep track), but it isn't that bad.

    No need for htaccess and rewrites on rewrites on rewrites.

    Basically what you're doing is setting up your primary mu site (blog_id 1) on site_id 1, and everything else gets site_id 2.

  7. jaredbangs
    Member
    Posted 17 years ago #

    Right, I've actually done it that way before as well (editing the core files), but I wouldn't recommend it to anyone.

    Outside of the standard maintenance / upgrade issues to keep track of, there's also the support nightmare that I could imagine (you guys would probably know better than I).

    Of course, there will occasionally be some things that can't be addressed any other way than editing the core files, but if you go that route be prepared to maintain what is essentially your own private fork of the codebase, and everything that goes along with that (including making it very difficult to ask for support in a forum like this).

    In this case, I'd say that if you wanted to consider it as a solution for this problem, make sure you take the time to learn and code it yourself, so that you know exactly what you're changing and why.

  8. drmike
    Member
    Posted 17 years ago #

    Donncha says in a ticket that our solution for multiple sites is what's causing the issue with the xmlrpc problems we're seeing though. :(

  9. lunabyte
    Member
    Posted 17 years ago #

    "Right, I've actually done it that way before as well (editing the core files), but I wouldn't recommend it to anyone."

    I would, as long as you keep track of what you edit. If there is a usable hook, cool. If not, there isn't any reason to be scared.

    That's the beauty of an apps source not being compiled. If I want it to do "X", I can make it happen. Provided I have a clue as to what I'm doing. Which, I do so yippy for me.

  10. jaredbangs
    Member
    Posted 17 years ago #

    Yeah, I think it's definitely up to the confidence / ability level of the person doing the work.

    For those who are familiar enough with PHP to understand what they're doing (to the degree that they probably wouldn't need to ask for help on how to do it here), then by all means, go for it.

    I still avoid it at all costs, but that's just my own personal opinion / preference.

  11. kp2575
    Member
    Posted 17 years ago #

    So the multi-site plugin is basically voodoo that doesn't really work and trying to use it will just cause problems down the road?

  12. lunabyte
    Member
    Posted 17 years ago #

    In regards to the OP, it looks like with 1.2.2 that Donncha released earlier today, that "most" of the editing could be done away with thanks to the sunrise.php file.

    Basically you would check to see if the domain being called was blogs.domain.tld, and if it is set the site_id to 1, if not, set it to 2 (etc).

    You'd still probably need to hack the cookie function though, so that it sets the cookie for any domain.tld domain (which would include blogs, and any subdomains). Still, this new addition will save probably 95% of the core edits for something like this.

  13. jaredbangs
    Member
    Posted 17 years ago #

    Yes, that was pretty awesome.

  14. WebDesigning
    Member
    Posted 17 years ago #

    I also like the information.

  15. plusarquitectura
    Member
    Posted 17 years ago #

    Lunabyte: I've tried to follow what you said in post #6: I added a new entry at wp_site table with my domain's name. No probs with it. But when accessing to wp-signup.php file, I couldn't find any $site_id variable, so I couldn't change any value from "1" to "2". Could you please be a little bit more specific? I'm not very used to php... :$

    I couldn't understand what you said about modyfing the cookie neither. How can I do it?

    Thank you one more time

  16. plusarquitectura
    Member
    Posted 17 years ago #

    After creating the new entry at "wp-site" table, I have changed all the instances of $site_id=1 to $site_id=2: three instances in wp-includes/wpmu-functions.php (in lines 706, 1166 and 1208) and one instance in wpmu-settings.php (in line 133).

    I've done nothing more. (I dind't understand what do I have to do with cookies and, more important, how am I to do it)

    When creating a new blog, it's still created on whatever.blogs.domain.tld instead of whatever.domain.tld

    What have I done wrong?

    Thanks again

  17. Bisente
    Member
    Posted 17 years ago #

    Why not doing this on the DNS? I mean, point domain.tld to one IP and blog1, blog2, blogn.domain.tld to another. You'll have to mess with the DNS anyway to define them, just point them to another IP.

    Or at the web-server level: define a virtual host for domain.tld and another one for the blogs with serveralias blog1, blog2, and so on. Or just make this the default for any hostname not already defined on other virtual-hosts.

    Either way you wouldn't need to touch the code. You will need to tweak the DNS or server config during the installation process to get wpmu installed under domain.tld, and then make the switch.

  18. drmike
    Member
    Posted 17 years ago #

    Because that's domain forwarding, not domain mapping. You'll get the incorrect URL in hte browser window, not the one that they want.

  19. Bisente
    Member
    Posted 17 years ago #

    No, that's not what I mean.

    Say you have your web on domain.tld. Ok, don't touch that. Get a server up somewhere else, on another IP. Put wpmu there. Edit your /etc/hosts file to point domain.tld to this new IP, then go to domain.tld and do the usual wpmu install and setup. Update the DNS so that blogX.domain.tld point to this second server and set the different blogs up. Then remove domain.tld from your /etc/hosts file. domain.tld would point to the original, unchanged web, and all the blogs to the new wpmu site. Wouldn't it work?

    After that you could even move everything to the original server in different virtual hosts, one for domain.tld and another one for the blogs, everything on the same server/IP.

  20. lunabyte
    Member
    Posted 17 years ago #

    That "might" work, but really it's overkill.

    If you simply have another virtual host on the existing setup (blogs.domain.tld) which comes before the original domain (domain.tld) in the conf file, then install it into blogs.domain.tld, and add the wildcard alias in this virtual host (so that *.domain.tld is rendered before the actual virtual host for domain.tld).

    Then simply add domain.tld as site_id #2 in the wp_site table, use the new sunrise php file that will set certain global variable values (like $current_site->domain) to a certain specified value, then it can be accomplished much easier.

    AFAIK, wp-settings.php will need to have a small edit still for setting cookies on .domain.tld instead of .blogs.domain.tld, but that's still minor compared to what would have needed to be edited originally before the new file functionality.

    I actually have a site that is set up on blogs.domain.tld, with users on user.domain.tld. Granted it was a small set-up to begin with, isn't used much as the "novelty" wore off, and I primarily use it for testing purposes now, but it's still setup the same way.

    Although the main site (domain.tld) is on a separate box, it really doesn't matter. As long as the vhost for blogs.domain.tld comes before the vhost for domain.tld in the conf file for apache, and the vhost for blogs.domain.tld has the wildcard edit, it still comes out OK because apache is going to render the first match as it scans through the vhosts.

    If you need to add something like forums.domain.tld, simply put that above the vhost for blogs.domain.tld, and then block users from registering with the name "forums" (or whatever, like wiki, support, etc).

  21. plusarquitectura
    Member
    Posted 17 years ago #

    lunabyte, I want to do what you say, but obviously I'm doing something wrong or I'm missing to do something, could you please give me a hand with it?

    After creating the new entry at "wp-site" table, I have changed all the instances of $site_id=1 to $site_id=2: three instances in wp-includes/wpmu-functions.php (in lines 706, 1166 and 1208) and one instance in wpmu-settings.php (in line 133).

    I've done nothing more. (I dind't understand what do I have to do with cookies and, more important, how am I to do it)

    When creating a new blog, it's still created on whatever.blogs.domain.tld instead of whatever.domain.tld

    What have I done wrong?

    Thanks again

  22. lunabyte
    Member
    Posted 17 years ago #

    There are a few places in wp-signup that passes the "domain" over to functions in wpmu-functions.php.

    You'll have to do a check on the domain, and check it to see if it equals "blogs.domain.tld", and if it does, reset the variable to be "domain.tld" instead.

    As for cookies, thats in wp-settings.php if I remember right, and you have to go look at when it sets the cookie, and make sure it sets it for .domain.tld instead of .blogs.domain.tld.

  23. plusarquitectura
    Member
    Posted 17 years ago #

    I'm sorry, I feel stupid on doing it, but I don't manage to make it work. I tried to follow lunabyte instructions with no good results.

    I created the new entry on the table,
    I changed all the $site_id=1 to $site_id=2 (and I did it using a massive find and replace, in all the directory files, so I'm sure not to have left any remaining).

    and that's what I didn't do:
    I didn't understand what do you mean by "You'll have to do a check on the domain, and check it to see if it equals "blogs.domain.tld", and if it does, reset the variable to be "domain.tld" instead." There's no single mention on any files about domain.tld nor blogs.domain.tld if not via variables (which I assume it's quite obvious -I'm not an expert at all about php, I'm more like a newbie)

    I opened wp-settings.php, there's no mention to domains.tld nor my domain, nor any $site_id=1 In fact I don't know what should I be looking for.

    and, just in case I'm not able to manage it (I hope with your help I will), what should I change if I wanted to modify original .htaccess?

    RewriteEngine On
    RewriteBase /

    #uploaded files
    RewriteRule ^(.*/)?files/$ index.php [L]
    RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule . - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]

  24. plusarquitectura
    Member
    Posted 17 years ago #

    I've read something about a Mu-plugin called "Multi-Site-Manager" but I didn't understand exactly how it works or what's its main purpose. WOuld it solve my issue if I used it? If so, how should I use it? I installed it but I don't succeed, which is mostly due to that I don't know it's main purpose.

    Thanks

  25. synapsestudios
    Member
    Posted 15 years ago #

    I had the same problem and was able to solve it without a plugin, changing anything in the database, or hacking core files. All I did was add the following to my wp-config.php file:
    define('COOKIE_DOMAIN','domain.com');

    Where "domain.com" is my root domain that I wanted to have *.domain.com work for in wpmu. This has the effect of fixing cookies when trying to login by making the cookie path be ".domain.com" instead of what it was before ".blogs.domain.com". That was what was causing problems when trying to login to "anything-else.domain.com".

    Hope this helps.

About this Topic

  • Started 17 years ago by plusarquitectura
  • Latest reply from synapsestudios