Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- Canonicalization: best code to redirect no-www to www & index to /


lucy24 - 2:29 am on Oct 16, 2012 (gmt 0)


I have 4 other addon domains. Not subdomains. With this code in place when I go to the addon domain it forces it to read in the url http: //www (dot)topleveldomain(dot)com/addondomain(dot)com

Careful. Are you talking about URLs or about physical location? I guess you're on shared hosting with multiple domains. The usual pattern is

/users/yourname/example.com
/users/yourname/example.org
/users/yourname/example.net

which lets you make two layers of htaccess files: a shared one for things like Deny From that apply across the board, and then one for each domain.

Have you instead got

/users/yourname/example.com
/users/yourname/example.com/example.org
/users/yourname/example.com/example.net

like that? Eeuw. Too late for you-- but for anyone else reading this: if you know beforehand that your host uses this configuration, start with a nothing domain that you won't even try to use, and put all the real stuff in the addons. You need all your domains to be parallel.

Can you show me what that would look like please?

The point is that requests for all the other domains will pass through the first domain's htaccess. (Assuming I've understood you right.) So anything that's specific to the first domain will always have to include a line that says

RewriteCond %{HTTP_HOST} !(other1|other2|other3)

You don't need to spell out the full names or use any anchors-- just say enough to distinguish them from the first domain. F'rinstance if you really did have dot com, dot org and dot net, then any rule that should apply only to dot com would be preceded by

RewriteCond %{HTTP_HOST} !\.(org|net)

You only need to do this when there is a chance of ambiguity, as with "index.html" redirects. If it's a specific filename that only exists in the first domain, you don't need any extra conditions.


Thread source:: http://www.webmasterworld.com/apache/4508251.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com