homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

setting up a subdomain through apache
apache subdomain setup virtual host

 11:23 pm on Oct 20, 2009 (gmt 0)

I was trying to follow other guides on here on how to set up a subdomain on my server using apache's virtual host feature.
No Luck Though.

My domain is registered with networksolutions and it forwards www, (none), (wildcards), and images to my server:
www.example.com -> our ip address -> http://www.example.com
example.com -> our ip address -> http://www.example.com
images.example.com -> our ip address -> http://www.example.com

The last example (images.example.com), I wanted to set up the virtual directory or host in apache. I think my current settings affect the http request for images.example.com

Current Config in Apache:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteRule ^(iqc)(.*) http://www.example.com/imagehosting.php?$2 [NC]

RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

Any Suggestions greatly appreciated.



 12:45 am on Oct 21, 2009 (gmt 0)

The final rule was given to you explictly to redirect requests for *anything* other than "www.example.com" or blank to "www.example.com". So if you need an exclusion to NOT redirect "images.example.com" then that last rule needs an additional RewriteCond to exclude that subdomain from the rule.



 1:16 am on Oct 21, 2009 (gmt 0)

How would I exclude it? Yet still maintain www.example.com?
Is there a way to have:
www.example.com [/htdocs/]
images.example.com [/htdocs/images/]
example.com -> (redirect to) -> www.example.com [/htdocs/]

and completely different site on the same server:
www.spidersimple.com [/htdocs/spidersimple/]

Thank you jd again.


 1:38 am on Oct 21, 2009 (gmt 0)

Of course there is, but you're going to need to put some work into this if this thread is to be a discussion...

Your rule currently excludes "www.example.com" from being rewritten. Given what's there, how do you think you might exclude "images.example.com" as well?

There are two ways to do it. One takes one extra line of code, the other doesn't even require an extra line...

I presume you have read the Apache mod_rewrite documentation and tutorials, but if not, I commend it to you. An apt term for using mod_rewrite without understanding it is "SEO suicide" -- and I offer that with the most sincere of intentions. As well, a review of our Charter here will reveal that our intent and purpose is to discuss and educate, not to serve as a free code-writing service or help desk. No one here gets paid...



 5:57 am on Oct 21, 2009 (gmt 0)

I should've tried to understand the coding.

...Sorry... (when it comes to regex I'm an r-tard)

Okay. I solved the directory issue so "www" and "images" is the only accepted sub directories.

For Others...my solution was:
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteCond %{HTTP_HOST} !^(images\.example\.com)?$

[edited by: jdMorgan at 1:05 pm (utc) on Oct. 21, 2009]
[edit reason] example.com [/edit]


 1:06 pm on Oct 21, 2009 (gmt 0)

Good work. But you don't need the 'allowance for blank' in both lines, so this will do:

RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteCond %{HTTP_HOST} !^images\.example\.com$

Or equivalently, the single line:

RewriteCond %{HTTP_HOST} !^((www¦images)\.example\.com)?$

but with the caveat that you must replace the broken pipe "¦" character with a solid pipe before use; POsting on this forum modifies the pipe characters.



 2:13 pm on Oct 21, 2009 (gmt 0)

Thank you Jim for your help! =)

So the Pipe Character is 'OR' just like in php and mysql?


 4:41 pm on Oct 21, 2009 (gmt 0)

Yes, as long as it is a solid pipe -- the broken ones are taken as literals, and the result of forgetting to 'fix' them is that the pattern never matches what you wanted to match.


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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved