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

After redirecting users in a Rails app, for some reason the slash after the domain is missing. Generated URLs are invalid and I'm forced to manually correct them. The problem only occurs on a subdomain. On a different primary domain (same server), everything works ok.

For example, after logging out, the site is directing to https://www.sub.domain.comlogin/ rather than https://www.sub.domain.com/login

I suspect the issue has something to do with the vhost setup, but I'm not sure. Here are the broken and working vhosts:

BROKEN SUBDOMAIN

<VirtualHost *:80>
  ServerName www.sub.domain.com
  ServerAlias sub.domain.com
  Redirect permanent / https://www.sub.domain.com
</VirtualHost>

<VirtualHost *:443>
  ServerAdmin email@email.com
  ServerName www.sub.domain.com
  ServerAlias sub.domain.com
  RailsEnv production

  # SSL Engine Switch
  SSLEngine on

  # SSL Cipher Suite:
  SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

  # Server Certificate
  SSLCertificateFile /path/to/server.crt

  # Server Private Key
  SSLCertificateKeyFile /path/to/server.key

  # Set header to indentify https requests for Mongrel
  RequestHeader set X_FORWARDED_PROTO "https"

  BrowserMatch ".*MSIE.*" \
  nokeepalive ssl-unclean-shutdown \
  downgrade-1.0 force-response-1.0

  DocumentRoot /home/usr/www/www.sub.domain.com/current/public/
  <Directory "/home/usr/www/www.sub.domain.com/current/public">
    AllowOverride all
    Allow from all
    Options -MultiViews
  </Directory>

WORKING PRIMARY DOMAIN

<VirtualHost *:80>
  ServerName www.diffdomain.com
  ServerAlias diffdomain.com
  Redirect permanent / https://www.diffdomain.com
</VirtualHost>

<VirtualHost *:443>
  ServerAdmin email@email.com
  ServerName www.diffdomain.com
  ServerAlias diffdomain.com
  ServerAlias *.diffdomain.com
  RailsEnv production

  # SSL Engine Switch
SSLEngine on

  # SSL Cipher Suite:
  SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

  # Server Certificate
SSLCertificateFile /path/to/server.crt

  # Server Private Key
SSLCertificateKeyFile /path/to/server.key

  # Set header to indentify https requests for Mongrel
  RequestHeader set X_FORWARDED_PROTO "https"

  BrowserMatch ".*MSIE.*" \
  nokeepalive ssl-unclean-shutdown \
  downgrade-1.0 force-response-1.0

  DocumentRoot /home/usr/www/www.diffdomain.com/current/public/
  <Directory "/home/usr/www/www.diffdomain.com/current/public">
    AllowOverride all
    Allow from all
    Options -MultiViews
  </Directory>
 </VirtualHost>

Please let me know if there's anything else I could provide that would help determine what's wrong here.

UPDATE tried adding a trailing slash to the redirect command, but still no luck.

share|improve this question

2 Answers 2

I'm fairly certain that you need the slash on the Redirect command:

  Redirect permanent / https://www.sub.domain.com/
share|improve this answer
    
unfortunately that didn't work, but thanks. –  joshee Dec 18 '12 at 16:38
up vote 0 down vote accepted

Asked another developer about this and here's how he fixed it:

I made new a vhost file for you. On previous vhost config, there was something wrong on server name and server alias. I removed 'www'. Also I added config.force_ssl = true to environments/production.rb

<VirtualHost *:80>
  ServerName sub.domain.com
  ServerAlias sub.domain.com www.sub.domain.com
  Redirect permanent / https://sub.domain.com
</VirtualHost>

<VirtualHost *:443>
  ServerAdmin email@email.com
  ServerName sub.domain.com
  ServerAlias sub.domain.com
  RailsEnv production
  RailsBaseURI /

  # SSL Engine Switch
  SSLEngine on

  # SSL Cipher Suite:
  SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

  # Server Certificate
  SSLCertificateFile /path/to/server.crt

  # Server Private Key
  SSLCertificateKeyFile /path/to/server.key

  # Set header to indentify https requests for Mongrel
  RequestHeader set X_FORWARDED_PROTO "https"

  BrowserMatch ".*MSIE.*" \
  nokeepalive ssl-unclean-shutdown \
  downgrade-1.0 force-response-1.0

  DocumentRoot /home/usr/www/www.sub.domain.com/current/public/
  <Directory "/home/usr/www/www.sub.domain.com/current/public">
    AllowOverride all
    Allow from all
    Options -MultiViews
  </Directory>
 </VirtualHost>
share|improve this answer

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.