1

My configuration in Apache VirtualHost file is:

<VirtualHost xxx.xxx.xxx.xxx:80> 
     ServerAdmin [email protected]
     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 [email protected]
     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?

1 Answer 1

3

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.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .