homepage Welcome to WebmasterWorld Guest from 54.161.247.22
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Subdomain canonical issues
Asia_Expat




msg:3903110
 11:48 am on Apr 29, 2009 (gmt 0)

I normally use subdirectories for main site sections. However, I've decided to use a subdomain for a new service I'm developing on my website. The trouble is that the main canonical redirect rule is causing the subdomain to redirect to the folder for that subdomain... i.e...

newservice.example.com

becomes

example.com/newservice/

What's the most appropriate way to handle this? I've trawled threough threads but it appears the answer is different for each server set up... so I post my htaccess file below, in the hope of some suggestions...

---------------------------------------

# Externally redirect direct client requests for index.xyz to "/" in same directory
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /(([^/]+/)*)index\.([xs]?html?¦php[456]?)(\?[^\ ]*)?\ HTTP/
RewriteCond %1 !^(forum¦oea)/
RewriteRule /?index\.([xs]?html?¦php[456]?)$ http://www.example.com/%1? [R=301,L]
#
# Externally redirect direct client requests for URLS with "page" file extensions
# to extensionless URLs
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /(([^/]+/)*[^./]+)\.([xs]?html?¦php[456]?)(\?[^\ ]*)?\ HTTP/
RewriteCond %1 !^(forum¦oea)/
RewriteRule \.([xs]?html?¦php[456]?)$ http://www.example.com/%1? [R=301,L]
#
# Externally redirect requests for non-blank, non-canonical hostname to canonical hostname
RewriteCond %{HTTP_HOST} !^(www\.(beta\.)?example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
###############################################
# Redirect to remove double slash within URL-path
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . http://www.example.com%1/%2 [R=301,L]
#
# Redirect to remove multiple slashes before URL-path
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ //+([^\ ]*)
RewriteRule .* http://www.example.com/%1 [R=301,L]
################################################
#######################################################
#
# Return 403-Forbidden response for included-object requests with non-blank off-site referrers
RewriteCond %{HTTP_REFERER} !^(https?://(www\.)?(beta\.)?example\.com(/.*)?)?$ [NC]
RewriteRule \.(jpe?g¦gif¦bmp¦png¦ico¦css¦js)$ - [NC,F]
#
# Skip the following three rules if the requested URL-path has a file extension, if it is
# blank (i.e. a "homepage" request), or if it exists as a directory when a slash is appended
RewriteCond $1 \.[a-z0-9]+$¦^$ [NC,OR]
RewriteCond %{REQUEST_FILENAME}/ -d
RewriteRule (.*) - [S=3]
#
# Internally rewrite extensionless URL request to existing .html file
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule (.+) /$1.html [L]
#
# Internally rewrite extensionless URL request to existing .xhtml file
RewriteCond %{REQUEST_FILENAME}.xhtml -f
RewriteRule (.+) /$1.xhtml [L]
#
# Internally rewrite extensionless URL request to existing .php file
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule (.+) /$1.php [L]

 

jdMorgan




msg:3903507
 7:19 pm on Apr 29, 2009 (gmt 0)

The new subdomain must be taken into account in *all* rules which generate external redirects -- either by including them in the rules' conditions, or by excluding them from the main domain's rules and reproducing those main domain's rules and modifying them to do the same function for the new subdomain, as required and/or preferred:

# Externally redirect direct client requests for index.xyz to "/" in same directory
RewriteCond %{HTTP_HOST} ^(www\.(beta\.)?example\.com) [OR]
RewriteCond %{HTTP_HOST} ^(newservice\.example\.com)
RewriteCond %1>%{THE_REQUEST} ^([^>]+)>[A-Z]+\ /(([^/]+/)*)index\.([xs]?html?如hp[456]?)(\?[^\ ]*)?\ HTTP/
RewriteCond %2 !^(forum她ea)/
RewriteRule /?index\.([xs]?html?如hp[456]?)$ http://%1/%2? [R=301,L]
#
# Redirect to remove double slash within URL-path
RewriteCond %{HTTP_HOST} ^(www\.(beta\.)?example\.com) [OR]
RewriteCond %{HTTP_HOST} ^(newservice\.example\.com)
RewriteCond %1>%{REQUEST_URI} ^([^>]+)>(.*)//(.*)$
RewriteRule . http://%1%2/%3 [R=301,L]
#
# Redirect to remove multiple slashes before URL-path
RewriteCond %{HTTP_HOST} ^(www\.(beta\.)?example\.com) [OR]
RewriteCond %{HTTP_HOST} ^(newservice\.example\.com)
RewriteCond %1>%{THE_REQUEST} ^([^>]+)>[A-Z]{3,9}\ //+([^\ ]*)
RewriteRule .* http://%1/%2 [R=301,L]
#
# Externally redirect direct client requests for URLS with "page" file extensions
# to extensionless URLs
RewriteCond %{HTTP_HOST} ^(www\.(beta\.)?example\.com) [OR]
RewriteCond %{HTTP_HOST} ^(newservice\.example\.com)
RewriteCond %1>%{THE_REQUEST} ^([^>]+)>[A-Z]+\ /(([^/]+/)*[^./]+)\.([xs]?html?如hp[456]?)(\?[^\ ]*)?\ HTTP/
RewriteCond %2 !^(forum她ea)/
RewriteRule \.([xs]?html?如hp[456]?)$ http://%1/%2? [R=301,L]
#
# Externally redirect requests for non-blank, non-canonical hostnames to canonical hostnames
# Canonicalize "newservice"
RewriteCond %{HTTP_HOST} newservice\.example\.com
RewriteCond %{HTTP_HOST} !^newservice\.example\.com$
RewriteRule (.*) http://newservice.example.com/$1 [R=301,L]
#
# Canonicalize all others
RewriteCond %{HTTP_HOST} !^(www\.(beta\.)?example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

Note that your original last two external redirect rules were not in the correct order: In general, to prevent unexpected and highly-undesirable results, all external redirects must go first, ordered from most-specific pattern (fewest URLs affected) to least-specific pattern (most URLs affected), followed by all internal rewrites, again ordered from most-specific pattern to least-specific pattern.

Replace all broken pipe "" characters with solid pipes before use; Posting on this forum modifies the pipe characters.

The character ">" that I added to most of the new RewriteConds is arbitrary; Although it (intentionally) implies concatenation, it has no "mod_rewrite coding" or regular-expressions function. It is just an arbitrary character (and one which will not appear within any valid hostname) whose sole purpose is to provide an unambiguous 'boundary marker' between the combined server variable strings, so that the patterns in the RewriteCond can separate-out their values correctly.

This complication was required in order to carry the matched currently-requested hostname from either of the first two RewriteConds through the third one. Without it, the third RewriteCond would over-write the value of %1, and the hostname would be lost.

Ther is another way to do it which you may prefer. You could reproduce the third rule and include the hostname tests in each copy. For example, your first rule:

# Externally redirect direct client requests for index.xyz to "/" in same directory
RewriteCond %{HTTP_HOST}>%{THE_REQUEST} ^(www\.(beta\.)?example\.com)>[A-Z]+\ /(([^/]+/)*)index\.([xs]?html?如hp[456]?)(\?[^\ ]*)?\ HTTP/ [OR]
RewriteCond %{HTTP_HOST}>%{THE_REQUEST} ^(newservice\.example\.com)>[A-Z]+\ /(([^/]+/)*)index\.([xs]?html?如hp[456]?)(\?[^\ ]*)?\ HTTP/
RewriteCond %2 !^(forum她ea)/
RewriteRule /?index\.([xs]?html?如hp[456]?)$ http://%1/%2? [R=301,L]

I *think* the method I used in the main code body above will be more efficient and/or easier to read and maintain.

I did a fair amount of chopping and hacking here; Hopefully, with no typos... :)

Jim

Asia_Expat




msg:3903823
 6:37 am on Apr 30, 2009 (gmt 0)

Thanks for your kind help Jim...

I've tested and I'm pretty sure everything is working as it should be... except the subdomains are still redirecting to the direcory, as in my original post.
I'm also wondering why we are seperating the 'beta' subdomain and the 'newservice' subdomain...

# Externally redirect requests for non-blank, non-canonical hostnames to canonical hostnames
# Canonicalize "translate"
RewriteCond %{HTTP_HOST} newservice\.example\.com
RewriteCond %{HTTP_HOST} !^newservice\.example\.com$
RewriteRule (.*) [newservice.example.com...] [R=301,L]
#
# Canonicalize all others
RewriteCond %{HTTP_HOST} !^(www\.(beta\.)?example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

Asia_Expat




msg:3903826
 6:43 am on Apr 30, 2009 (gmt 0)

... Incidentally, the following works properly (i.e. if you include the 'www')...

www.beta.example.com

With that knowledge, If it means greater efficiency and a simpler htaccess file, I'm happy to use www.newservice.example.com instead of newservice.example.com

... but then, I guess there is a risk of dupe content issues if the non-www subdomain continues to redirect to the folder.

[edited by: Asia_Expat at 6:53 am (utc) on April 30, 2009]

jdMorgan




msg:3904007
 1:40 pm on Apr 30, 2009 (gmt 0)

I copied the "beta" bit from your original code. I don't know what "beta" means to you, nor how you use it.

Don't change your requirements to suit the code, make the code conform to your requirements. However, if you need help here, then you must state those requirements clearly.

If you have three canonical hostnames, "www.example.com", "beta.example.com", and "newservice.example.com", then the code becomes:

# Externally redirect direct client requests for index.xyz to "/" in same directory, removing query string
RewriteCond %{HTTP_HOST}>%{THE_REQUEST} ^((www在eta好ewservice)\.example\.com)>[A-Z]+\ /(([^/]+/)*)index\.([xs]?html?如hp[456]?)(\?[^\ ]*)?\ HTTP/
RewriteCond %3 !^(forum她ea)/
RewriteRule /?index\.([xs]?html?如hp[456]?)$ http://%1/%3? [R=301,L]
#
# Redirect to remove double slash within URL-path
RewriteCond %{HTTP_HOST}>%{REQUEST_URI} ^((www在eta好ewservice)\.example\.com)>(.*)//(.*)$
RewriteRule . http://%1%3/%4 [R=301,L]
#
# Redirect to remove multiple slashes before URL-path
RewriteCond %{HTTP_HOST}>%{THE_REQUEST} ^((www在eta好ewservice)\.example\.com)>[A-Z]{3,9}\ //+([^\ ]*)
RewriteRule .* http://%1/%3 [R=301,L]
#
# Externally redirect direct client requests for URLS with "page" file extensions
# to extensionless URLs
RewriteCond %{HTTP_HOST}>%{THE_REQUEST} ^((www在eta好ewservice)\.example\.com)>[A-Z]+\ /(([^/]+/)*[^./]+)\.([xs]?html?如hp[456]?)(\?[^\ ]*)?\ HTTP/
RewriteCond %3 !^(forum她ea)/
RewriteRule \.([xs]?html?如hp[456]?)$ http://%1/%3? [R=301,L]
#
# Externally redirect requests for non-blank, non-canonical hostnames to canonical hostnames
#
# Canonicalize "newservice"
RewriteCond %{HTTP_HOST} newservice\.example\.com
RewriteCond %{HTTP_HOST} !^newservice\.example\.com$
RewriteRule ^(.*)$ http://newservice.example.com/$1 [R=301,L]
#
# Canonicalize "beta"
RewriteCond %{HTTP_HOST} beta\.example\.com
RewriteCond %{HTTP_HOST} !^beta\.example\.com$
RewriteRule ^(.*)$ http://beta.example.com/$1 [R=301,L]
#
# Canonicalize all others
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

Jim

[edited by: jdMorgan at 1:41 pm (utc) on April 30, 2009]

Asia_Expat




msg:3904209
 5:27 pm on Apr 30, 2009 (gmt 0)

Jim,
My apologies for any ambiguity above. I will attempt to be very clear hence...

My htaccess is designed to:
*Create cruft free URIs accross my website
*Redirect 'index.blah' to '/' in all directories
*Clean up double//////multiple slashes
*Remove blank queries (although it doesn't do that very well)
*Exclude the 'forum' and 'oea' directories from query string removal as the software within is totally reliant on query strings
*I have the three canonical hostnames you mention above
*Deny hotlinking from all domains except the aforementioned canonical domains

-----------------------------------

Back to your most helpful chopping and hacking...

Unfortunately the subdomains were still redirecting to the directory... i.e. newservice.example.com' becomes 'www.example.com/newservice'
However, as I always have a stab at figuring things out for myself, I have figured out that particular problem by myself. The problem is the following line...

# Canonicalize all others
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$

... which I have changed to...

# Canonicalize all others
RewriteCond %{HTTP_HOST} ^orientexpat\.com$ [NC]

This seems to have fixed things up to a degree and 'newservice.example.com' now works.

However, if I type in 'www.newservice.example.com'... it becomes 'newservice.example.com/newservice/'

Furthermore, cruft free URLs under the subdomains don't work properly. To clarify this, '/example.html' successfully redirects to '/example' but a 404 is produced, even though the file exists.

The htaccess as it is right now, follows...

# Externally redirect direct client requests for index.xyz to "/" in same directory, removing query string
RewriteCond %{HTTP_HOST}>%{THE_REQUEST} ^((www在eta好ewservice)\.example\.com)>[A-Z]+\ /(([^/]+/)*)index\.([xs]?html?如hp[456]?)(\?[^\ ]*)?\ HTTP/
RewriteCond %3 !^(forum她ea)/
RewriteRule /?index\.([xs]?html?如hp[456]?)$ [%1...] [R=301,L]
#
# Redirect to remove double slash within URL-path
RewriteCond %{HTTP_HOST}>%{REQUEST_URI} ^((www在eta好ewservice)\.example\.com)>(.*)//(.*)$
RewriteRule . [%1%3...] [R=301,L]
#
# Redirect to remove multiple slashes before URL-path
RewriteCond %{HTTP_HOST}>%{THE_REQUEST} ^((www在eta好ewservice)\.example\.com)>[A-Z]{3,9}\ //+([^\ ]*)
RewriteRule .* [%1...] [R=301,L]
#
# Externally redirect direct client requests for URLS with "page" file extensions
# to extensionless URLs
RewriteCond %{HTTP_HOST}>%{THE_REQUEST} ^((www在eta好ewservice)\.example\.com)>[A-Z]+\ /(([^/]+/)*[^./]+)\.([xs]?html?如hp[456]?)(\?[^\ ]*)?\ HTTP/
RewriteCond %3 !^(forum她ea)/
RewriteRule \.([xs]?html?如hp[456]?)$ [%1...] [R=301,L]
#
# Externally redirect requests for non-blank, non-canonical hostnames to canonical hostnames
#
# Canonicalize "newservice"
RewriteCond %{HTTP_HOST} newservice\.example\.com
RewriteCond %{HTTP_HOST} !^newservice\.example\.com$
RewriteRule ^(.*)$ [newservice.example.com...] [R=301,L]
#
# Canonicalize "beta"
RewriteCond %{HTTP_HOST} beta\.example\.com
RewriteCond %{HTTP_HOST} !^beta\.example\.com$
RewriteRule ^(.*)$ [beta.example.com...] [R=301,L]
#
# Canonicalize all others
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
#
# Return 403-Forbidden response for included-object requests with non-blank off-site referrers
RewriteCond %{HTTP_REFERER} !^(https?://(www\.)?(beta\.)?(newservice\.)?example\.com(/.*)?)?$ [NC]
RewriteRule \.(jpe?g夙if在mp如ng夷co圭ss夸s)$ - [NC,F]
#
# Skip the following three rules if the requested URL-path has a file extension, if it is
# blank (i.e. a "homepage" request), or if it exists as a directory when a slash is appended
RewriteCond $1 \.[a-z0-9]+$回$ [NC,OR]
RewriteCond %{REQUEST_FILENAME}/ -d
RewriteRule (.*) - [S=3]
#
# Internally rewrite extensionless URL request to existing .html file
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule (.+) /$1.html [L]
#
# Internally rewrite extensionless URL request to existing .xhtml file
RewriteCond %{REQUEST_FILENAME}.xhtml -f
RewriteRule (.+) /$1.xhtml [L]
#
# Internally rewrite extensionless URL request to existing .php file
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule (.+) /$1.php [L]

[edited by: Asia_Expat at 5:39 pm (utc) on April 30, 2009]

Asia_Expat




msg:3904236
 5:55 pm on Apr 30, 2009 (gmt 0)

... oh, and I wonder, in order to help my understanding, if you could explain in a little more detail why...

RewriteCond %1 !^(forum她ea)/

becomes

RewriteCond %2 !^(forum她ea)/

and then becomes

RewriteCond %3 !^(forum她ea)/

[edited by: Asia_Expat at 5:56 pm (utc) on April 30, 2009]

jdMorgan




msg:3904393
 8:50 pm on Apr 30, 2009 (gmt 0)

Back-references of the $1 through $9 form refer to the part of the requested URL-path matching the first through ninth parenthesized sub-pattern in the RewriteRule pattern.

Back-references of the 51 through 59 form refer to the part of the string matching the first through ninth parenthesized sub-pattern in the last-matched (single) RewriteCond pattern.

I'll look at the code again in a bit -- kinda tied-up today.

Jim

jdMorgan




msg:3904421
 9:11 pm on Apr 30, 2009 (gmt 0)

Ugh, I forgot a line:

# Externally redirect direct client requests for index.xyz to "/" in same directory, removing query string
RewriteCond %{HTTP_HOST}>%{THE_REQUEST} ^((www在eta好ewservice)\.example\.com)>[A-Z]+\ /(([^/]+/)*)index\.([xs]?html?如hp[456]?)(\?[^\ ]*)?\ HTTP/
RewriteCond %3 !^(forum她ea)/
RewriteRule /?index\.([xs]?html?如hp[456]?)$ http://%1/%3? [R=301,L]
#
# Redirect to remove multiple consecutive slashes within URL-path
RewriteCond %{HTTP_HOST}>%{REQUEST_URI} ^((www在eta好ewservice)\.example\.com)>(.*)//+(.*)$
RewriteRule . http://%1%3/%4 [R=301,L]
#
# Redirect to remove multiple consecutive slashes before URL-path
RewriteCond %{HTTP_HOST}>%{THE_REQUEST} ^((www在eta好ewservice)\.example\.com)>[A-Z]{3,9}\ //+([^\ ]*)
RewriteRule .* http://%1/%3 [R=301,L]
#
# Externally redirect direct client requests for URLS with "page" file extensions
# to extensionless URLs
RewriteCond %{HTTP_HOST}>%{THE_REQUEST} ^((www在eta好ewservice)\.example\.com)>[A-Z]+\ /(([^/]+/)*[^./]+)\.([xs]?html?如hp[456]?)(\?[^\ ]*)?\ HTTP/
RewriteCond %3 !^(forum她ea)/
RewriteRule \.([xs]?html?如hp[456]?)$ http://%1/%3? [R=301,L]
#
# Externally redirect requests for non-blank, non-canonical hostnames to canonical hostnames
#
# Canonicalize "newservice"
RewriteCond %{HTTP_HOST} newservice\.example\.com
RewriteCond %{HTTP_HOST} !^newservice\.example\.com$
RewriteRule ^(.*)$ http://newservice.example.com/$1 [R=301,L]
#
# Canonicalize "beta"
RewriteCond %{HTTP_HOST} beta\.example\.com
RewriteCond %{HTTP_HOST} !^beta\.example\.com$
RewriteRule ^(.*)$ http://beta.example.com/$1 [R=301,L]
#
# Canonicalize all others
RewriteCond %{HTTP_HOST} example\.com$ [NC]
[b]RewriteCond %{HTTP_HOST} !^(www好ewservice在eta)\.example\.com$[/b]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
#
# Return 403-Forbidden response for included-object requests with non-blank off-site referrers
RewriteCond %{HTTP_REFERER} !^(https?://(www\.)?(beta\.)?(newservice\.)?example\.com(/.*)?)?$ [NC]
RewriteRule \.(jpe?g夙if在mp如ng夷co圭ss夸s)$ - [NC,F]
#
# Skip the following three rules if the requested URL-path has a file extension, if it is
# blank (i.e. a "homepage" request), or if it exists as a directory when a slash is appended
RewriteCond $1 \.[a-z0-9]+$回$ [NC,OR]
RewriteCond %{REQUEST_FILENAME}/ -d
RewriteRule (.*) - [S=3]
#
# Internally rewrite extensionless URL request to existing .html file
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule (.+) /$1.html [L]
#
# Internally rewrite extensionless URL request to existing .xhtml file
RewriteCond %{REQUEST_FILENAME}.xhtml -f
RewriteRule (.+) /$1.xhtml [L]
#
# Internally rewrite extensionless URL request to existing .php file
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule (.+) /$1.php [L]

Replace the broken pipe characters with solid ones, flush cache before testing, etc...

Jim

[edited by: jdMorgan at 9:12 pm (utc) on April 30, 2009]

Asia_Expat




msg:3904877
 11:54 am on May 1, 2009 (gmt 0)

After thorough testing (I spent around an hour testing every potential dupe issue I can think of)... nearly everything appear to be functioning perfectly... except for two things...

Re: the subdomains... 'www.newservice.example.com'... still becomes 'newservice.example.com/newservice/'

Another issue I've been unable to resolve is blank queries. I've studied the relevant line for a while, and I sincerely promise I'm making the effort to absorb whatever I can from these free lessons, but I'm fried. For example...

www.goodness-gracious.com/great-scott/ooh-crikey
www.goodness-gracious.com/great-scott/ooh-crikey?
www.goodness-gracious.com/great-scott/ooh-crikey?

... all resolve the same content :-(

+ cruft free URLs under the subdomains still don't work properly. To clarify this, '/example.html' successfully redirects to '/example' but a 404 is produced, even though the file exists.

EDIT: the last example above had multiple ? mark but the forum software removed them.

[edited by: Asia_Expat at 12:50 pm (utc) on May 1, 2009]

jdMorgan




msg:3905007
 3:11 pm on May 1, 2009 (gmt 0)

There is no code in the thread above that handles rewriting subdomains to subdirectories. The likely problem is that that code (wherever it is) is interfering with the code discussed here.

If the code to rewrite subdomains to subdirectories is in this file, it must follow the oft-repeated "rule of thumb": All external redirects go first, in order from most-specific pattern (fewest URLs affected) to least-specific pattern (most URLs affected), followed by all internal rewrites, again in order from most-specific pattern (fewest URLs affected) to least-specific pattern. (If you put a rewrite ahead of a redirect, then that redirect, if invoked, will 'expose' the internally-rewritten filepath to the client as a URL.

There are no provisions in the code here to handle blank query strings, so they will all resolve as if the "?" were not present in the request.

Jim

Asia_Expat




msg:3905015
 3:23 pm on May 1, 2009 (gmt 0)

The only other things in the htaccess are listed below the dotted lines...
I've just checked any htaccess files in any folder above and below and I can't see anything else that might be interfering.
Do you have any suggestions where I might look? I'm running a cPanel server.

----------------------------------------

AddType application/x-httpd-php .html .xhtml
Options -Indexes

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName example.com

ErrorDocument 404 /404.php

[edited by: Asia_Expat at 3:23 pm (utc) on May 1, 2009]

Asia_Expat




msg:3905034
 3:42 pm on May 1, 2009 (gmt 0)

I've just been poking around in httpd.conf and spotted this...

ServerName beta.example.com
ServerAlias www.beta.example.com

Is this the problem?

jdMorgan




msg:3905049
 4:16 pm on May 1, 2009 (gmt 0)

No, that just assures that both variants will resolve to the filesystem. If that wasn't there, then you wouldn't be able to redirect www.beta.example.com to beta.example.com at all -- www.beta.example.com simply would not exist, and the default server page would be the only thing accessible on that sub-sub-domain.

We are looking for the answer to the question, "What mechanism is being used to map the newservice.example.com URLs to the /newservice subdirectory in the filesystem?"

If this is done using some "control panel" method, then you will likely have to have separate --and substantially-duplicate-- .htaccess files in the root directory for each subdomain. (I hate control panels and name-based (as opposed to IP-based) virtual hosting for this reason.)

Jim

Asia_Expat




msg:3905058
 4:26 pm on May 1, 2009 (gmt 0)

Will moving the contents of htaccess to the httpd.conf file help? I've actually been planning to start a thread titled 'httpd.conf for dummies' :-D

g1smd




msg:3905065
 4:46 pm on May 1, 2009 (gmt 0)

If you move stuff to httpd.conf, then you need to be aware that in .htaccess that the RewriteRule does not see the leading slash on the URL, but in httpd.conf it does. You'll need to adjust your rules accordingly.

Asia_Expat




msg:3905166
 7:56 pm on May 1, 2009 (gmt 0)

OK thanks g1smd, I'll go ahead and start a new thread...

I don't think this thread has any further to go, as it's clear it's most likely a cPanel issue affecting my code... but just to round it off, is migrating the code to the httpd.conf file likely to make the canonical fixups work?

[edited by: Asia_Expat at 7:58 pm (utc) on May 1, 2009]

jdMorgan




msg:3905208
 9:16 pm on May 1, 2009 (gmt 0)

We are looking for the answer to the question, "What mechanism is being used to map the newservice.example.com URLs to the /newservice subdirectory in the filesystem?"

This is a critical question. Don't leave base until you know the answer.

Jim

Asia_Expat




msg:3906018
 8:10 pm on May 3, 2009 (gmt 0)

I've posted this issue in the cPanel customer forum but I'm not getting much luck yet.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved