I had mantis setup as www.example.com/mantis and now I've setup my httpd.conf to have it accessible at: mantis.example.com . Since I have many links referencing the earlier links, I need to redirect them to the new location.

This is what I have as my httpd.conf now:

```
<VirtualHost MYSERVERIP:80>
    ServerAlias EXAMPLE.com
    DocumentRoot /var/www/html/beta
    ServerName EXAMPLE.com
    UseCanonicalName On

 <IfModule mod_rewrite.c>
    RewriteEngine On

RewriteLogLevel 5
RewriteLog "/var/www/html/htaccess.log"

RewriteRule ^/mantis/(.*) http://mantis.EXAMPLE.com/$1 [L,R=301]

RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
...
 </IfModule>
</VirtualHost>

...

<VirtualHost MYSERVERIP:80>
    ServerAlias mantis.EXAMPLE.com
    DocumentRoot /var/www/html/mantis
    ServerName mantis.EXAMPLE.com
    UseCanonicalName On
</VirtualHost>

```

However, accessing <http://www.EXAMPLE.com/mantis/view.php?id=17575> leads to: 

```
http://guide.opendns.com/main?url=www.mantis.EXAMPLE.com%2Fview.php%3Fid%3D17575 

```

which shows:

```
You tried to visit www.mantis.EXAMPLE.com, which is not loading.

```

**Note the www. part. I dont understand where its coming from!!**

The htaccess logs are as follows:

```
MYCLIENTIP - - [27/May/2011:09:40:57 +0000] [EXAMPLE.com/sid#2b4fab862578][rid#2b4fabeec150/initial] (2) init rewrite engine with requested uri /mantis/view.php
MYCLIENTIP - - [27/May/2011:09:40:57 +0000] [EXAMPLE.com/sid#2b4fab862578][rid#2b4fabeec150/initial] (3) applying pattern '^/mantis/(.*)' to uri '/mantis/view.php'
MYCLIENTIP - - [27/May/2011:09:40:57 +0000] [EXAMPLE.com/sid#2b4fab862578][rid#2b4fabeec150/initial] (2) rewrite '/mantis/view.php' -> 'http://mantis.EXAMPLE.com/view.php'
MYCLIENTIP - - [27/May/2011:09:40:57 +0000] [EXAMPLE.com/sid#2b4fab862578][rid#2b4fabeec150/initial] (2) explicitly forcing redirect with http://mantis.EXAMPLE.com/view.php
MYCLIENTIP - - [27/May/2011:09:40:57 +0000] [EXAMPLE.com/sid#2b4fab862578][rid#2b4fabeec150/initial] (1) escaping http://mantis.EXAMPLE.com/view.php for redirect
MYCLIENTIP - - [27/May/2011:09:40:57 +0000] [EXAMPLE.com/sid#2b4fab862578][rid#2b4fabeec150/initial] (1) redirect to http://mantis.EXAMPLE.com/view.php?id=17575 [REDIRECT/301]

```

Related: [httpd.conf changes to allow www.mysite.com and www.mysite.com/mantis and phpmyadmin?](https://serverfault.com/questions/269309/httpd-conf-changes-to-allow-www-mysite-com-and-www-mysite-com-mantis-and-phpmyadm)

---

Edit 1

After changing httpd.conf to:

```
RewriteLogLevel 5
RewriteLog "/var/www/html/htaccess.log"

RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteRule ^/mantis/(.*) http://mantis.EXAMPLE.com/$1 [L,R=301]

```

No luck still.

The log file is as:

```
MYCLIENTIP - - [27/May/2011:10:41:12 +0000] [EXAMPLE.com/sid#2b4fab856518][rid#2b4fabf06640/initial] (2) init rewrite engine with requested uri /mantis/view.php
MYCLIENTIP - - [27/May/2011:10:41:12 +0000] [EXAMPLE.com/sid#2b4fab856518][rid#2b4fabf06640/initial] (3) applying pattern '^' to uri '/mantis/view.php'
MYCLIENTIP - - [27/May/2011:10:41:12 +0000] [EXAMPLE.com/sid#2b4fab856518][rid#2b4fabf06640/initial] (4) RewriteCond: input='www.EXAMPLE.com' pattern='!^www\.' => not-matched
MYCLIENTIP - - [27/May/2011:10:41:12 +0000] [EXAMPLE.com/sid#2b4fab856518][rid#2b4fabf06640/initial] (3) applying pattern '^/mantis/(.*)' to uri '/mantis/view.php'
MYCLIENTIP - - [27/May/2011:10:41:12 +0000] [EXAMPLE.com/sid#2b4fab856518][rid#2b4fabf06640/initial] (2) rewrite '/mantis/view.php' -> 'http://mantis.EXAMPLE.com/view.php'
MYCLIENTIP - - [27/May/2011:10:41:12 +0000] [EXAMPLE.com/sid#2b4fab856518][rid#2b4fabf06640/initial] (2) explicitly forcing redirect with http://mantis.EXAMPLE.com/view.php
MYCLIENTIP - - [27/May/2011:10:41:12 +0000] [EXAMPLE.com/sid#2b4fab856518][rid#2b4fabf06640/initial] (1) escaping http://mantis.EXAMPLE.com/view.php for redirect
MYCLIENTIP - - [27/May/2011:10:41:12 +0000] [EXAMPLE.com/sid#2b4fab856518][rid#2b4fabf06640/initial] (1) redirect to http://mantis.EXAMPLE.com/view.php?id=17575 [REDIRECT/301]

```