|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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 |
|
#2
|
|||
|
|||
|
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 ![]() |
|
#3
|
|||
|
|||
|
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. |
|
#4
|
||||
|
||||
|
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 |
|
#5
|
|||
|
|||
|
>> 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. |
|
#6
|
||||
|
||||
|
>> 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 |
|
#7
|
|||
|
|||
|
Then put those in .htaccess in your docroot.
|
|
#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?
|
|
#9
|
|||
|
|||
|
>> 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. |
|
#10
|
||||
|
||||
|
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 |
|
#11
|
|||
|
|||
|
>> 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. |
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > mod_rewrite - A few answers. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|