homepage Welcome to WebmasterWorld Guest from 54.145.183.126
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Apache httpd.conf verify subdomain www is www utilizing apache
verify www using apache
miketheman

5+ Year Member



 
Msg#: 4009958 posted 10:13 am on Oct 20, 2009 (gmt 0)

Hi everyone. LOVE THE FORUM! can't believe how much it has helped me. I'm trying to configure my apache's configuration file to verify that the subdomain is on the server.

The problem that I've run into is cookies are enabled for www.domain.com I currently use this snippet (think I even found it on here) to redirect [domain.com...] requests to [domain.com...]

Snippet:
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ [domain.com...] [L,R=301]

What I've been losing hair folicles over is, some users find it fun (or something) to go to:
whatevertheywant.domain.com
which then removes settings that are set by cookies.

Is there a way to only allow www.domain.com (or a subdomain...will post about that too in a different topic).

THANK YOU SO MUCH FOR THE HELP!

 

jdMorgan

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



 
Msg#: 4009958 posted 3:49 pm on Oct 20, 2009 (gmt 0)

You should have also found this snippet, which uses a negative match to ensure that only "www" is accessible:

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

The allowance for a blank HTTP_HOST prevents an infinite loop if the request is from a true HTTP/1.0 client (they don't send the Host header, leaving that variable blank, which would cause a loop if not handled).

Jim

miketheman

5+ Year Member



 
Msg#: 4009958 posted 7:05 pm on Oct 20, 2009 (gmt 0)

Thank you jdMorgan....Your really awesome, your postings have helped me out so much!

miketheman

5+ Year Member



 
Msg#: 4009958 posted 11:13 pm on Oct 20, 2009 (gmt 0)

An extra slash gets added to the end of my url when I go to...
example.com
the result is then converted, because of the settings below in my apache config
http://www.example.com//
This doesn't affect my server from serving pages properly, just trying to understand why it does this. With it doing this of course it also turns all links to
http://www.example.com//login.dll

any suggestions. Thank you much.....

Below is the code snippet:
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]


BY THE WAY JDMORGAN....your code worked flawlessly. Thank you again.

miketheman

5+ Year Member



 
Msg#: 4009958 posted 12:31 am on Oct 21, 2009 (gmt 0)

Nevermind...I solved it.

In case others need a solution, I changed the slash at the end in lines 3 and 7:
RewriteRule ^(.*)$ http://www.example.com$1 [L,R=301]
RewriteRule ^(.*)$ http://www.example.com$1 [R=301,L]

So far this works fine so don't know if it will cause any errors later.

jdMorgan

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



 
Msg#: 4009958 posted 12:34 am on Oct 21, 2009 (gmt 0)

For use in httpd.conf, but *outside* of any <Directory> container, your RewriteRule patterns should start with a slash, as in ^/(.*)$ and ^/(iqc)(.*)$

Note that in that second case, the first set of parentheses isn't needed, since you are discarding "iqc". So you can remove those parentheses, and back-reference $1 instead of $2.

Jim

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