skip to Main Content

This is my scenario:

  1. I have my Symfony 3.3 app deployed at my domain with cpanel in a dedicated hosting in Godaddy.
  2. My document root is not public_html, it is a subfolder in public_html
  3. With http I can access normally to my website
  4. When I installed the ssl certificate in cpanel successfully and then I update my .htaccess under web folder to redirect to https, the site was redirected to public_html folder, not to public_html/subfolder/web, just like it was occur with http normally.

Please, some one can help me with this problem?

I hope that change my Symfony web folder to public_html folder are not the only solution.

UPDATE 1

My .htaccess file

DirectoryIndex app.php
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c>
    RewriteEngine On
    # start https
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    # end https
    RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::2$
    RewriteRule ^(.*) - [E=BASE:%1]
    RewriteCond %{HTTP:Authorization} .
    RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^app.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ - [L]
    RewriteRule ^ %{ENV:BASE}/app.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        RedirectMatch 302 ^/$ /app.php/
    </IfModule>
</IfModule>

UPDATE 2

I found the problem and the solution, that´s why I changed the title of the question, because the problem was not with Symfony, was with Apache virtual host configuration.

2

Answers


  1. Chosen as BEST ANSWER

    One of the comments of Ramazan give me a new idea to search the solution. Well, I found it here To deploy my site in a subfolder into public_html I needed to change the virtual host configuration, but, I only modified the main file, not the _SSL config file. Then, the solution in this link is worked for me.


  2. You can solve this problem by using security configuration. Here is a example https://symfony.com/doc/current/security/force_https.html

    or routing

    https://symfony.com/doc/current/routing/scheme.html

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search