Current time: 04-18-2014, 04:16 PM Hello There, Guest! (LoginRegister)

Post Reply 
mod_rewrite and wildcard dns
04-18-2007, 07:07 AM
Post: #21
mod_rewrite and wildcard dns
^([^.)\.antishift.org is invalid. i think what you want is ^([^\.]<plus>)\.antishift\.org$ -- that matches anything without a dot (at least one character) in the parenthesis, followed by .antishift.org -- since it's enclosed in ^...$ it can't have anything before or after it. so it will match subdomain.antishift.org but not subsubdomain.subdomain.antishift.org.

the <plus> is supposed to be a plus sign, but the forum keeps turning it into a space.

track7 - my dream-hosted site
Visit this user's website Find all posts by this user
Quote this message in a reply
04-18-2007, 07:39 AM
Post: #22
mod_rewrite and wildcard dns
^([^\.]<plus>)\.antishift\.org$ changing the <plus> to a + makes regular sites work correctly, but whenever I go to any subdomain.antishift.org it no longer redirects and I now get an error for nothing being there.
Find all posts by this user
Quote this message in a reply
04-18-2007, 01:31 PM
Post: #23
mod_rewrite and wildcard dns
I'm pretty sure that's because you DO actually need wildcard DNS. The redirect happens in 3 layers:

- DNS resolves *.example.com to the IP of your webserver (requires wildcard dns)

- webserver looks at the HTTP headers to see which hostname is being requested and turns wild.example.com into example.com, and looks to the example.com directory in your user folder as the DocumentRoot

- webserver loads the .htaccess file from your /home/user/example.com/ directory, reads and parses the rewriterules, and then redirects accordingly.

So the DNS aspect of it is just as important as the RewriteRules -- you are depending on both and they both need to be set up.
Find all posts by this user
Quote this message in a reply
04-18-2007, 05:32 PM
Post: #24
mod_rewrite and wildcard dns
Okay, it's working now.. almost! Tongue There's just one problem - usernames that start with an 'm' don't work right. Is this because 'm' is disabled? How can I fix this :/ Thanks!
Find all posts by this user
Quote this message in a reply
04-18-2007, 09:10 PM
Post: #25
mod_rewrite and wildcard dns
Glad to hear you got it mostly working.

Earlier I suggested using

RewriteCond %{HTTP_HOST} !^(www|andy|m)

Which you should change to

RewriteCond %{HTTP_HOST} !^(www|andy|m)\.antishift\.org$

And this will not redirect for:
http://www.antishift.org
andy.antishift.org
m.antishift.org

Cool openvein.org -//- One-time $50.00 discount on DreamHost plans: Use ATROPOS7
Visit this user's website Find all posts by this user
Quote this message in a reply
04-18-2007, 09:30 PM
Post: #26
mod_rewrite and wildcard dns
Awesome Smile It works!

Now I'm wondering..

I had it at

RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www|m)\.antishift\.org$
RewriteCond %{HTTP_HOST} ^([^\.]+).antishift.org$
RewriteRule .* http://www.antishift.org/browse.php?disp...sername=%1

This worked perfectly for subdomains, however, I wanted to also add in folders to www. So I turned it into

RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www|m)\.antishift\.org$
RewriteCond %{HTTP_HOST} ^([^\.]+).antishift.org$
RewriteCond %{HTTP_HOST} ^www.antishift.org/([^\.]+)/$
RewriteRule .* http://www.antishift.org/browse.php?disp...sername=%1

With this, the subdomains still worked, but the http://www.antishift.org/name/ just stayed there and didn't redirect anywhere. Do I have to do a whole extra thing or can I only do one at a time? How does this work?

By the way, I haven't properly thanked *all* of you, which I really need to. You've all helped me a lot and without you, I would be way lost. Thanks so much for all of your help and work Smile
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: