0

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 2

1

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

Sign up to request clarification or add additional context in comments.

6 Comments

Hi, thanks, but the .htaccess is correct? or I need to use security configuration without .htaccess?
I suggest you examine this. stackoverflow.com/a/10703421/2210147
I tryed that, and this is what the browser are showing: The requested URL /en was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. If I remove /en from the url then my problem persist, the site is redirect to public_html folder and not to public_html/subfolder/web
It is something like the document root for 443 is diferent of the document root for 80. My dedicated hosting is on GoDaddy. Do you know if I need to modify the virtual host config for 443 port?
Delete this RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] Would you try this. RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
|
0

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.

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.