Welcome to WebmasterWorld Guest from 54.198.187.30

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Wildcard Subdomains on an Aliased Domain for WP mu

How to use WP mu subdomain feature for an aliased domain with godaddy.

     
5:56 pm on Dec 7, 2007 (gmt 0)

New User

5+ Year Member

joined:Dec 7, 2007
posts: 7
votes: 0


Hello All,

I've run into a bit of a setup issue. I have a primary domain being hosted with a dedicated IP. That works fine. Then I have another domain. It's Aliased to the primary domain but is served out of a different directory.

So primarydomain.com is in root. A generic Wordpress install.
Next domain is otherdomain.com it's in /nextdomain. It is a Wordpress MU install. I really need to be able to subdomain here. This will allow WP mu to handle blog1.nextdomain.com and blog2.nextdomain.com and so on.

Normally, I would open the DNS "control panel" from my host, make a new A Record to wildcard everything. However, when I created a wildcard A Record on nextdomain.com, all subdomains went to primarydomain.com. At that point, primarydomain.com has no idea of what to do with blog1.primarydomain.com or blog2.

My host says, "hey, you can fix that with the .htaccess file." So I'm all, "OK. That's what I figured. I'll get to it." No luck.

So... how to get the wildcard subdomains in the aliased domain for Wordpress MU is the question. If I modify the .htaccess, is it the .htaccess in root or in /nextdomain?

My .htaccess is still really generic:
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]

Thanks.

12:03 am on Dec 8, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


You need to modify the .htaccess file in the root of primarydomain, assuming that that is where the wildcard subdomains currently 'land' when requested.

By checking the requested subdomain and domain, your code can then 'sort them out' into subdirectories, or attach a query string to the request indicating the requested subdomain -- whatever you want to do.

The subject of rewriting subdomains to subdirectories has been well-covered here, and a search for "rewrite subdomain subdirectory rewritecond http_host rewriterule" (or similar) should turn up several of them.

Jim

9:52 pm on Dec 9, 2007 (gmt 0)

New User

5+ Year Member

joined:Dec 7, 2007
posts: 7
votes: 0


Thanks Jim. I was thinking the root was the right place. All a little new to me so your reply in pointing me to the right places to research was perfect. With so much info here, it's daunting to figure out where to start.
Thanks.
6:42 pm on Dec 11, 2007 (gmt 0)

New User

5+ Year Member

joined:Dec 7, 2007
posts: 7
votes: 0

OK. I have basically run into a brick wall. I updated the .htaccess in the primary domain in root. It now contains this:
Options +FollowSymlinks
RewriteEngine on
RewriteBase /

#handle otherdomain.org wildcard subdomains
RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).otherdomain.org [NC]
RewriteRule (.*) /otherdomain [L]

#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]

The problem is that when the condition hits and the rule is followed, the URI is otherdomain.org/otherdomain/

That's a major issue. Going through the posts got me this far, but I've run out of steam. Any thoughts?

6:54 pm on Dec 11, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


The problem is that when the condition hits and the rule is followed, the URI is otherdomain.org/otherdomain/

What URL did you request? What URL did you expect? What filepath should that URL resolve to? And please confirm: You are seeing otherdomain.com/otherdomain in your browser's address bar?

That's a major issue. Going through the posts got me this far, but I've run out of steam. Any thoughts?

What, specifically, is the issue?

I don't mean to be pedantic here, but please understand that the other members and I may read and try to respond to several dozen threads per day here, so the more specific you can be, the less confused we'll be... :) (Even at the cost of repetition, clear and complete examples of the desired and actual results are good.)

Thanks,
Jim

7:18 pm on Dec 11, 2007 (gmt 0)

New User

5+ Year Member

joined:Dec 7, 2007
posts: 7
votes: 0


I'm happy to repeat/clarify considering the response time. Let me try again using more standard vernacular and better details while maintaining some anonymity since that seems to be the standard...

- I own domain1.com and domain2.com.
- They are hosted with GoDaddy; dedicated IP, Linux, Apache, etc.
- I have installed WordPress MU on domain1.com and domain2.com
- Within the directory structure to which I have access, domain1.com lives in / (I call this root).
- domain2.com lives in /domain2com (I am a very simple human)
- The idea of WordPress MU is that you run your own WordPress.org action. That is to say that limitless blogs can be created at domain1.com; e.g. blog1.domain1.com, blog2.domain1.com, blogN.domain.com.
-- Proper setup means setting wildcard DNS via A Record: * = Dedicated Ip Address. DONE
-- WordPress MU handles it from there.
- The same is true for domain2.com.
- Unfortunately this is where we ran into earlier problems. blogN.domain2.com was going to blogN.domain1.com... bad deal. So we made the RewriteCond and RewriteRule. Then some magic occured. domain2.com seemed to understand... I was able to create blog1.domain2.com.
- When I tried to go to blog1.domain2.com after create, I actually went to a URL of [blog1.domain2.com...] While the blog contents came up... the images/themes were nonexistant, a 404 from not finding content.php in the middle of the page, etc.

The .htaccess remains as it was in my last reply.

I hope this helps and thanks for your continued patience.

8:53 pm on Dec 11, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


Ah, OK. So your browser is now resolving relative URLs based on the new URL -- as it should. See this post: [webmasterworld.com...]

Again, when you get an error, it is very helpful if you post the requested URL and the filepath it resolved to (look in your server error log).

Jim

9:30 pm on Dec 11, 2007 (gmt 0)

New User

5+ Year Member

joined:Dec 7, 2007
posts: 7
votes: 0


That doesn't really apply in my situation... or so it would seem. I'm at godaddy, so not to sure where to find the server logs to look at the error. Probably not going to be able to resolve this. The issue is regarding wildcarding against an aliased domain. If more detailed information is needed or you want to take things for a drive to see what's under the hood, please email me.
9:36 pm on Dec 11, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


I hope you found the right post in that thread. It may explain why your includes don't work. If page-relative links are used, the browser will resolve them based on the "page" address it sees in its address bar.

Also, based on your description of seeing /domain2 in the URL, you have an external redirect being invoked some time after the internal rewrites above are invoked, and that is a problem. None of the code you've posted includes a redirect, so that problem is elsewhere.

Jim

10:11 pm on Dec 11, 2007 (gmt 0)

New User

5+ Year Member

joined:Dec 7, 2007
posts: 7
votes: 0


let's try backing up since I don't seem to be moving forward at this point.

Adding this to my .htaccess file in the root directory made the wildcards work on both domain1 and domain2... sort of:

#handle example.org wildcard subdomains
RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).domain2.com [NC]
RewriteRule (.*) /domain2com [L]

Now the images/themes and includes are all jacked (technically speaking). It's wordpress, so I don't really have much to play with here.

Should I make changes to the .htaccess in /domain2com?

[edited by: jdMorgan at 10:54 pm (utc) on Dec. 11, 2007]
[edit reason] examplified [/edit]

10:58 pm on Dec 11, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


Yes, possibly. Your images and other includes not working are classic symptoms of the effect of rewriting to a subdirectory when on-page page-relative links are used. The reference I cited above describes the situation, and points to another thread that addresses how to fix the problem.

If the internal redirect to /domain2 is being 'exposed' in your browser address bar, then that is a second problem, and is likely caused by another redirect, possibly in /domain2. You need to make sure that all redirects are executed first, and only then followed by internal rewrites, if you want those internal rewrites to be 'silent' and not appear in the address bar.

Jim

12:57 am on Dec 12, 2007 (gmt 0)

New User

5+ Year Member

joined:Dec 7, 2007
posts: 7
votes: 0


lex parsimoniae

This has become too complicated. I was under the assumption it would be relatively simple but thread after thread of issues that don't seem to fit, as a .htaccess hacker wannabee, I'm left with a bunch of failed .htaccess files, no access to logs, and using the latin phrase for Occam's razor. This should be simpler.

Any request that comes in for *.domain2.com should be responded by the app hosted in /domain2com.

Any request for domain1.com should be responded by the app hosted in /

That seems very succinct to me. The other threads talk about fixing up URLs for search engines or stripping an ID out and slapping it on the end of a querystring. Not my issue at all.

Making the experience tolerable is how willing you are to continue to help. Care to go one more round?

Thanks

1:26 am on Dec 12, 2007 (gmt 0)

Preferred Member

10+ Year Member

joined:May 4, 2004
posts:525
votes: 0


Would it not be better to use this rule instead of the one which was posted up and down for a while now?

#handle example.org wildcard subdomains 
RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).domain2.com [NC]
RewriteCond %{SCRIPT_FILENAME}
!^/domain2com [NC] 
RewriteRule ^(.*)$ /domain2com/$1 [L]
2:17 am on Dec 12, 2007 (gmt 0)

New User

5+ Year Member

joined:Dec 7, 2007
posts: 7
votes: 0


That did it. You are the man, Jim. Thanks for putting up with my ignorance. All is working now.

Thanks.

Wish I knew what the rule was doing. I've downloaded a reg ex primer to try to figure it out during my non-existent spare time. :(

3:21 am on Dec 12, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


Well, gergoe deserves the thanks and the credit -- I'm afraid I did not see the error in that rule at all, and I don't know the latin for "too close to the forest to see the trees"... :)

Jim

3:49 am on Dec 12, 2007 (gmt 0)

New User

5+ Year Member

joined:Dec 7, 2007
posts: 7
votes: 0


Right you are Jim.

Thanks a ton gergoe. Worked brilliantly. Guess I need to pass a pint through my monitor as is the tradition.

Cheers!

11:17 am on Dec 12, 2007 (gmt 0)

Preferred Member

10+ Year Member

joined:May 4, 2004
posts:525
votes: 0


Strange, here in Hungary we say "does not see the forest because of the tree", but in English it is just the opposite? Anyway, I'm glad it's solved.
2:43 pm on Dec 12, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


gergoe,

In English, it's similar -- "cannot see the forest for the trees" and other variations, but I modified it to better fit this situation, with the "trees" being analogous to the fine details such as the missing "/$1".

Thanks for helping out around here!

Jim

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members