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 have a apache server using two SSL domains (no SNI support) in different ports, kinda like this:

I have a Rewrite rule to redirect http://host2.tld:80 to :444 (and the same to host1). Then there is the problem:

I have a folder "folder" on host2 root. If I try to access http://host2.tld/folder/, everything is ok and I end up in https://host2.tld:444/folder/ as expected. Now, if I type http://host2.tld/folder, apache redirect me to http://host2.tld:444/folder/, which doesn't exist.

Since the redirection from "folder" to "folder/" is automatically done, what can I do to fix my problem?

Mod-rewrite config:

<VirtualHost *:80>
    ServerName host2.tld
    RewriteEngine On
    RewriteRule (.*) https://%{HTTP_HOST}:444%{REQUEST_URI} [R=301,L]
</VirtualHost>
share|improve this question
3  
Please post your config. At the very least, the mod_rewrite config in question. –  Shane Madden Sep 28 '11 at 19:08
    
Configuration added. –  Jr. Hames Sep 28 '11 at 20:32
    
So, wait, I'm confused. Is the problem the addition of the trailing slash, or is the problem the setting of the scheme to http on the redirect to port 444? –  Shane Madden Sep 28 '11 at 22:22
    
Is there any .htaccess or another .conf file which is included? –  quanta Sep 29 '11 at 3:00
    
The problem is that when omitting the trailing slash, apache redirect to http://host2.tld:444/folder/ (instead of https) resulting in a bad request. If I put the trailing slash, everything works fine. –  Jr. Hames Sep 29 '11 at 14:02

1 Answer 1

Remove the L from your rewrite rule. That option indicates that rule is the 'last' rule and no further rewriting will occur.

When you go to http://host2.tld/folder it rewrites the uri to add the slash, but doesn't process any further.

You may also want/need to add a condition to the rewrite in order to prevent a loop on every request.

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.