0

Normal VHOST:

<VirtualHost *:80>
DocumentRoot /var/www/html/app/current/web
ServerAdmin [email protected]
ServerName app.foobar
ServerAlias www.app.foobar
<Directory /var/www/html/app/current/web>
        AllowOverride None
        Order Allow,Deny
        Allow from All      

        <IfModule mod_rewrite.c>
            Options Indexes FollowSymlinks
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !HTTP/1.1$
            RewriteRule ^(.*)$ app.php [QSA,L]
        </IfModule>
</Directory>

<IfModule mod_headers.c> 
  Header set X-XSS-Protection "1; mode=block" 
</IfModule>
</VirtualHost>    

HTTPS VHOST:

<VirtualHost *:443>    
DocumentRoot /var/www/html/app/current/web
ServerName app.foobar
ServerAdmin [email protected]
<Directory /var/www/html/app/current/web>
AllowOverride None
Order Allow,Deny
Allow from All
<IfModule mod_rewrite> 
Options Indexes FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !HTTP/1.1$
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule> 
</Directory>
SSLEngine on
SSLProtocol +TLSv1 +TLSv1.1 +TLSv1.2
SSLCertificateFile /ssl/app.foobar/app.foobar.crt
SSLCertificateKeyFile /ssl/app.foobar/app.foobar.key
SSLCACertificateFile /ssl/app.foobar/app.foobar.ca-bundle
</VirtualHost>    

As the title says when I use regular port 80 the urls are rewritten to use app.php but when I try to use https port 443 I get a directory listing instead. How do I get the url rewritten with https like it does with http?

1
  • I've just been digging through the apache mod_rewrite documentation and found the FallbackResource directive. This seems to work. But why is this not in the Symfony documentation? Commented Mar 8, 2017 at 2:10

1 Answer 1

1

I solved this by using the FallbackResource directive available in Apache 2.2.16+.

In the official Symfony docs this directive is not used to remain backwards compatible with older version of Apache. Discussion is here.

Code example:

<Directory /var/www/html/app/current/web>
    AllowOverride None
    Order Allow,Deny
    Allow from All      

    <IfModule mod_rewrite.c>
        FallbackResource /app.php
    </IfModule>
</Directory>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.