# Apache HTTP redirection (SOLVED)

## Akaihiryuu

I want Apache to redirect certain URL's only to HTTPS.  Basically, right now I have Roundcube and Phpmyadmin both installed, in /roundcube, and /phpmyadmin, and I'd like these to redirect to HTTPS if entered through HTTP.

I've done some experimenting with mod_redirect without any luck.

```
RewriteEngine On

RewriteCond %{HTTPS} !=on

RewriteRule ^roundcube(.*) https://%{SERVER_NAME}:8443/roundcube$1 [R,L]
```

I put that in .htaccess in the Roundcube directory and that did not work.  What am I doing wrong?Last edited by Akaihiryuu on Wed Feb 22, 2012 3:21 pm; edited 1 time in total

----------

## Akaihiryuu

Also tried putting the following in my vhost configuration, it doesn't work at all...just gives a server error when I try to load one of the sites that involves rewrite.  I tried many similar examples too and nothing works.

```
<Directory "/var/www/www.internal.lan/htdocs/roundcube">

       RewriteEngine On

       RewriteCond %{HTTPS} off

       RewriteRule (.*) https://%{HTTP_HOST}:8443%{REQUEST_URI}

</Directory>

<Directory "/var/www/www.internal.lan/htdocs/phpmyadmin">

       RewriteEngine On

       RewriteCond %{HTTPS} off

       RewriteRule (.*)$ https://%{HTTP_HOST}:8443%{REQUEST_URI}

</Directory>
```

----------

## Akaihiryuu

Fixed by changing {HTTP_HOST} to {SERVER_NAME} in the example above.

----------

