Welcome to WebmasterWorld Guest from 54.146.59.202

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Apache httpd.conf verify subdomain www is www utilizing apache

verify www using apache

     
10:13 am on Oct 20, 2009 (gmt 0)

5+ Year Member



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!

3:49 pm on Oct 20, 2009 (gmt 0)

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



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

7:05 pm on Oct 20, 2009 (gmt 0)

5+ Year Member



Thank you jdMorgan....Your really awesome, your postings have helped me out so much!
11:13 pm on Oct 20, 2009 (gmt 0)

5+ Year Member



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.

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

5+ Year Member



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.

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

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



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

 

Featured Threads

Hot Threads This Week

Hot Threads This Month