LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Redirect Apache (mod_rewrite) from subdomain to https directory (vhost) (https://www.linuxquestions.org/questions/linux-newbie-8/redirect-apache-mod_rewrite-from-subdomain-to-https-directory-vhost-878110/)

accessthecloud 05-01-2011 04:52 AM

Redirect Apache (mod_rewrite) from subdomain to https directory (vhost)
 
Hopefully I can find an answer here...

On one of my servers (Centos 5.5), I have been hosting a particularly complex CRM application for one of my clients. Recently they have asked about configuring SSL connections to the CRM. Problem is, SSL is already configured for their main domain but not the sub-domain where the CRM application is accessed.

Rather than purchasing another SSL certificate for their sub-domain (and probably another IP address), would it be possible to setup a redirection from the subdomain to a sub-directory in the SSL directory using mod_rewrite. I have searched online and through the other posts on LinuxQuestions but nothing I have tried works.

For example:

All requests made to http://sub.domain.com would be rewritten/redirected to https://domain.com/sub

Although this looks fairly simple, I have configured (Plesk) multiple virtual hosts that may cause problems.

Thanks in advance for any assistance.

bathory 05-01-2011 08:10 AM

Hi,

You can use Recirect inside the vhost definition of sub.domain.com
Code:

<VirtualHost ...>
...
ServerName sub.domain.com
Redirect / https://domain.com/sub/
...
</VirtualHost>

Regards

accessthecloud 05-02-2011 07:07 AM

Thanks, I wonder why I was thinking I needed something more complex?

This is perfect


All times are GMT -5. The time now is 05:08 PM.