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.

I managed to redirect my requests from port 80 to 443 using the redirect permanent.

However, there is a problem. On my page there is a link to /forum/. When one clicks the link it tries to go to https://futureretrogaming.comforum with no slashes.

What can be done about this?

<VirtualHost *:80>
    ServerAdmin kevin.miller@futureretrogaming.com
    DocumentRoot "/var/www/frg"
    ServerName www.futureretrogaming.com
    ServerAlias futureretrogaming.com
    ServerAlias futureretrogaming.net
    ServerAlias www.futureretrogaming.net
    ErrorLog "/var/www/frg/log/error.log"
    CustomLog "/var/www/frg/log/access.log" common
    <Directory /var/www/frg>
                DirectoryIndex index.html index.php
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
    </Directory>
    Redirect permanent / https://futureretrogaming.com/
</VirtualHost>
share|improve this question

1 Answer 1

up vote 1 down vote accepted

Try using mod_rewrite instead of a simple Redirect. First, make sure your Apache setup has mod_write enabled by running this command; this works for Ubuntu/Debian:

sudo a2enmod rewrite 

Then restart Apache; again this works for Ubuntu/Debian:

sudo service apache2 restart

And your server should now be able to handle mod_write instructions. So adjust your virtual host config like so:

<VirtualHost *:80>
    ServerAdmin kevin.miller@futureretrogaming.com
    DocumentRoot "/var/www/frg"
    ServerName www.futureretrogaming.com

    ServerAlias futureretrogaming.com
    ServerAlias futureretrogaming.net
    ServerAlias www.futureretrogaming.net

    ErrorLog "/var/www/frg/log/error.log"
    CustomLog "/var/www/frg/log/access.log" common

    <Directory /var/www/frg>
        DirectoryIndex index.html index.php
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    // Redirect permanent / https://futureretrogaming.com/
    RewriteEngine on
    ReWriteCond %{SERVER_PORT} !^443$
    RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]

</VirtualHost>

If you notice I commented out the Redirect you had in place & added some spacing for readability. And you can check this from the command line using curl -I like this:

curl -I http://futureretrogaming.com/forum

And the results I see right now show this working:

HTTP/1.1 302 Found
Date: Fri, 30 May 2014 02:03:46 GMT
Server: Apache/2.2.22 (Ubuntu)
Location: https://futureretrogaming.com/forum
Vary: Accept-Encoding
Content-Type: text/html; charset=iso-8859-1

Somewhat unrelated but since I am noticing it, you can also make your life a bit easier by consolidating & simplifying some of the ServerAlias stuff:

ServerAlias futureretrogaming.com
ServerAlias futureretrogaming.net
ServerAlias www.futureretrogaming.net

Instead of 3 lines that could be all consolidated into one line:

ServerAlias futureretrogaming.* www.futureretrogaming.*

The wildcard covers all top level domains such as .com, .net & even .org as well as others.

share|improve this answer
    
It says RewriteEngine is an invalid command –  Kyle May 30 at 1:52
    
@Kyle Your server probably needs to have mod_rewrite enabled. Will update. –  JakeGould May 30 at 1:53
    
Thanks for the update, how do I enable mod_rewrite is that just a apt-get install deal? –  Kyle May 30 at 1:56
    
@Kyle Nope. No need to run apt-get unstall. Please read my recent edit near the top of the answer. If you are on Ubuntu/Debian then simply run sudo a2enmod rewrite then run sudo service apache2 restart & you should be set for this configuration to work. –  JakeGould May 30 at 1:57
    
futureretrogaming.comforum is still what is happening –  Kyle May 30 at 2:02

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.