Forum Moderators: phranque
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.
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
#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?
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?
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
- 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.
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
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
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]
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
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