hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : Odd <host>.domain.com redirection
Reply

Hosting Security and Technology Configuring and optimizing web hosting servers and operating systems, developing administration scripts, building servers, protecting against hackers, and general security (SSL certificates, etc.)
Forum Jump

Odd <host>.domain.com redirection

Reply Post New Thread In Hosting Security and Technology Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 08-30-2001, 11:49 AM
huck huck is offline
Linux Support Specialist
 
Join Date: Apr 2001
Location: FL, USA
Posts: 850

Odd <host>.domain.com redirection


I want to be able to redirect sites from anything.domain.com to www.domain.com. So, I setup some RewriteRules to do this for me. I made sure to set up the DNS with a wildcard to catch all of the various possibilities.

Now host.domain.com works, aljdljfdljfldjf.domain.com works but get this:
anything.domain.com does not work
What is going on here.
Relevant httpd.conf snippets
Code:
ServerAlias *.domain.com

RewriteEngine on
RewriteCond %{HTTP_HOST}                !^domain.com(:80)?$
RewriteCond %{HTTP_HOST}                !^www.domain.com(:80)?$
RewriteRule ^/(.*)                      http://www.domain.com/$1 [L,R]

Any clues???? Just curious.

__________________

We save you time, money, and frustration by handling the server management tasks required to run an online business successfully.
No prodding required. We just do it right the first time. Red Hat, MySQL, Plesk, and cPanel certified staff.


Reply With Quote


Sponsored Links
  #2  
Old 08-30-2001, 01:09 PM
Jm4n Jm4n is offline
WHT Addict
 
Join Date: Aug 2001
Posts: 137
Personally I wouldn't use mod_rewrite -- your ServerAlias directive will make sure they see the same content no matter what URL they use. I don't really see the need to redirect the user. I'm not sure it's worth the overhead of mod_rewrite...

That said, this isn't tested, but try changing the last line to:
Code:
RewriteRule ^(/.*)?    http://www.domain.com$1 [L,R]
I'm not positive, but I don't think the trailing slash will necessarily always be there (or perhaps a :80 might be before it, in which case you'll need to further modify it...)

Again, not tested, but you might look at your logs and make sure the requested URI would actually match the conditions and the regex.

__________________
- Jman

Reply With Quote
  #3  
Old 08-30-2001, 01:44 PM
huck huck is offline
Linux Support Specialist
 
Join Date: Apr 2001
Location: FL, USA
Posts: 850
Nevermind ...
It seems to be working now, which is odd. I am not sure why it did not work before.


As for mod_rewrite, I use it for other purposes as well, which is why it is enabled. Cobalt Raqs use mod_rewrite and mod_perl to dyanamically build up redirection for the site admin panel.

As far as redirecting the user -- this ensures that they end up at www.domain.com as opposed to something else, which provides consistency.

If the trailing slash is not there, then I think the RewriteCond should fail, thus no rewritting.
Code:
RewriteCond %{HTTP_HOST}                !^domain.com(:80)?$

__________________

We save you time, money, and frustration by handling the server management tasks required to run an online business successfully.
No prodding required. We just do it right the first time. Red Hat, MySQL, Plesk, and cPanel certified staff.


Reply With Quote
Sponsored Links
  #4  
Old 08-30-2001, 03:19 PM
Jm4n Jm4n is offline
WHT Addict
 
Join Date: Aug 2001
Posts: 137
If the trailing slash is not there, then I think the RewriteCond should fail, thus no rewritting.

Not when you're checking HTTP_HOST -- this wouldn't contain any part of the URI, only what the brower sends in the Host: header... so it should match no matter what URI is passed in the GET request.

What I meant was the RewriteRule's regex -- though now that my brain has decided to cooperate, I realize of course that the browser will always issue a "GET /", thus the slash will always be part of the request URI

So, nevermind me...

__________________
- Jman

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Host Europe Group Launches Domain Management Service for SMEs Web Hosting News 2013-04-24 14:31:28
Domain Registrar Domain.com Launches goMobi Mobile Web Solution Web Hosting News 2012-08-24 17:32:25
Web Host Domain.com Targets Startups with "Next Great Idea" at TechCrunch Disrupt Event Web Hosting News 2012-05-18 10:56:15
Host Europe Acquires Spanish Domain Registrar and Web Host RedCoruna Web Hosting News 2012-01-23 09:56:35
Web Host Go Daddy Says Outage Due to Software Upgrade Web Hosting News 2011-06-14 16:54:29


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?