Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 3rd, 2002, 11:47 AM
djl's Avatar
djl djl is offline
PHPer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: London, UK.
Posts: 469 djl User rank is Private First Class (20 - 50 Reputation Level)djl User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 10 h 29 m
Reputation Power: 8
Question mod_rewrite - A few answers.

Ok, im quite intrigued as to how to redirect a subdomain.domain.com to a secure (SSL) connection, eg. https://domain.com

So, i had a look into mod_rewrite thinking this is for me.
I've read through quite a few of the posts here and have a learnt a lot just by looking.
But to be honest, i havent a clue what i might be looking for to redirect to an SSL connection.

Is there a different way to write these conditions down for the mod_rewrite?

Theres also a few other things that ideally i would like to be explained to me

What do $l and also $2 do?

I think that should do me for the moment.

Thanks to all who respond

David

Reply With Quote
  #2  
Old March 3rd, 2002, 01:02 PM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 42 m 50 sec
Reputation Power: 184
i recommend reading http://httpd.apache.org/docs/misc/rewriteguide.html

and some articles about regexps (also posts in this forums about regexps.) $1 and $2 are back-references. they refer to the parts of your regexp that you put in brackets

Reply With Quote
  #3  
Old March 3rd, 2002, 04:06 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
From http://subdomain.domain.com to https://domain.com?

You will need to give us more details. Like under what condition should a request of http://subdomain.domain.com be redirected to https://domain.com.

Further, domain.com is not a FQDN, it should not be configured with SSL in the first place.

Reply With Quote
  #4  
Old March 3rd, 2002, 04:48 PM
djl's Avatar
djl djl is offline
PHPer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: London, UK.
Posts: 469 djl User rank is Private First Class (20 - 50 Reputation Level)djl User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 10 h 29 m
Reputation Power: 8
Thank you both for your answers.

freebsd: ok, i have a control panel in operation on one of my domains. To get to this you need to type in https://myhostdomain.com:8443

This is obviously a secure connection.
I would ideally like to somehow enable people to just type in lets say http://panel.myhostdomain.com and be redirected.

I was having a look in the Apache manual (http://httpd.apache.org/docs/misc/rewriteguide.html).
It seemed to say (to me anyway) that if i had access to the DNS, which i do, i could add a DNS A record and then use the following:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.[^.]+\.host\.com$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^www\.([^.]+)\.host\.com(.*) /home/$1$2

Obviously this would direct www.panel.host.com to www.host.com/panel

Could this sort of way be doctored or adapted to suit my needs or am i totally getting the wrong end of the stick!?

Thanks again,

David

Reply With Quote
  #5  
Old March 3rd, 2002, 04:58 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> just type in lets say http://panel.myhostdomain.com and be redirected.

So the condition is whenever there is a request to panel.myhostdomain.com. Then try this:

RewriteEngine on
RewriteRule ^(.*) https://myhostdomain.com:8443$1 [R,L]

Place this within <VirtualHost> of panel.myhostdomain.com.

Reply With Quote
  #6  
Old March 3rd, 2002, 05:12 PM
djl's Avatar
djl djl is offline
PHPer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: London, UK.
Posts: 469 djl User rank is Private First Class (20 - 50 Reputation Level)djl User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 10 h 29 m
Reputation Power: 8
>> Place this within <VirtualHost> of panel.myhostdomain.com.

Is that going to be within the httpd.conf file?
If so, i dont have direct access to this.
I only have the ability to add the different DNS types through a control panel that i access.

Any more suggestions or am i interprutting this wrong also!?

David

Reply With Quote
  #7  
Old March 3rd, 2002, 07:40 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Then put those in .htaccess in your docroot.

Reply With Quote
  #8  
Old March 4th, 2002, 01:55 PM
djl's Avatar
djl djl is offline
PHPer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: London, UK.
Posts: 469 djl User rank is Private First Class (20 - 50 Reputation Level)djl User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 10 h 29 m
Reputation Power: 8
One last question:

If i placed just:
RewriteEngine on
RewriteRule ^(.*) https://myhostdomain.com:8443$1 [R,L]

In a .htaccess file surely that will look for any subdomain @ myhostdomain.com and then redirect?

Or is this just me being stupid.
Actually thinking about it now, would i have to add in the DNS A type and then this .htaccess file would look to that?

*confused*

Thanks again,

David
__________________
-----
Do you fear the obsolescence of the metanarrative apparatus of legitimation?

Reply With Quote
  #9  
Old March 5th, 2002, 12:23 AM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> will look for any subdomain @ myhostdomain.com and then redirect?

That's why you need to put those into the appropriate .htaccess, the docroot of panel.myhostdomain.com specifically.

>> would i have to add in the DNS A type

Whenever you configure vhost, that ServerName must be able to resolve to an IP. That said, you can't blindly create whatever.myhostdomain.com when it's not resolvable.

Reply With Quote
  #10  
Old March 5th, 2002, 03:32 AM
djl's Avatar
djl djl is offline
PHPer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: London, UK.
Posts: 469 djl User rank is Private First Class (20 - 50 Reputation Level)djl User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 10 h 29 m
Reputation Power: 8
Right, yes, i think i know what you saying now

I shall give that a go once my domain name is fully resolved.

Thanks again for your assistance, most helpful

David

Reply With Quote
  #11  
Old March 5th, 2002, 10:50 AM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> I shall give that a go once my domain name is fully resolved

Yes. And when it comes to mod_rewrite with HTTP_HOST, that HTTP_HOST must be DNS resolvable, else mod_rewrite can't do rewriting to the URI part or whatever. Resolving a FQDN to its IP is a DNS requirement for Apache.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > mod_rewrite - A few answers.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT