Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

My configuration in Apache VirtualHost file is:

<VirtualHost xxx.xxx.xxx.xxx:80> 
     ServerAdmin hq@abcdefg.com
     ServerName abcdefg.com
     ServerAlias www.abcdefg.com
     DocumentRoot /var/www/abcdefg.com/public/abcdefg/current/public/
     ErrorLog /var/www/abcdefg.com/logs/error.log 
     CustomLog /var/www/abcdefg.com/logs/access.log combined
     <Directory /var/www/abcdefg.com/public/abcdefg/current/public>
         AllowOverride all
         Options -MultiViews
     </Directory>
     <Location /blog>
         PassengerEnabled off # turn off Passenger for /blog subdirectory
     </Location>
     <Location /support>
         PassengerEnabled off # turn off Passenger for /support subdirectory
     </Location>
     <Location /stats>
         PassengerEnabled off # turn off Passenger for /stats subdirectory
     </Location>
     RewriteEngine On
     RewriteRule ^/blog/?(.*)$ /var/www/abcdefg.com/blog/public_html/$1 [NC,QSA,L]
     RewriteRule ^/support/?(.*)$ /var/www/abcdefg.com/support/public_html/$1 [NC,QSA,L]
     RewriteRule ^/stats/?(.*)$ /var/www/abcdefg.com/stats/public_html/$1 [NC,QSA,L]
     RewriteCond %{HTTP_HOST} ^www\.abcdefg\.com [NC]
     RewriteRule ^(.*)$ http://abcdefg.com/$1 [L,R=301]
</VirtualHost>

<VirtualHost xxx.xxx.xxx.xxx:443>
     SSLEngine On
     SSLCertificateFile /etc/apache2/ssl/apache.pem
     SSLCertificateKeyFile /etc/apache2/ssl/apache.key
     ServerAdmin hq@abcdefg.com
     ServerName q1
     DocumentRoot /var/www/abcdefg.com/public/abcdefg/current/public/
     ErrorLog /var/www/abcdefg.com/logs/error.log 
     CustomLog /var/www/abcdefg.com/logs/access.log combined
</VirtualHost>

When I type www.abcdefg.com, it results in http://abcdefg.com// with the double slash at the back. How can I fix this?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

The culprit is your final RewriteRule - drop the trailing slash before the $1:

RewriteRule ^(.*)$ http://abcdef.com$1

This seems unintuitive, but the reason is that the first / (which is always implied, even when not typed) is caught in the capture and included in the new URL.

share|improve this answer
    
Thanks! Works well. –  Victor Apr 13 '11 at 17:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.