简体   繁体   中英

Getting forbidden 403 error only on https but url http working fine

on my server I have wordpress site on root and codeigniter project as sub folder in wordpress and I made subdomain for codeigniter project. Both are working fine without SSL Now I want to apply SSL on subdomain project while applying ssl on this I am facing issue. When I am opening site by using https://subdomain.example.com it is giving me forbidden 403 error.

Following is the example of my sites hosted on apache. I had symbolic link for my root wordpress project.

http://example.com - working fine - wordpress project on root

http://subdomain.example.com - working fine - codeigniter project under wordpress project folder

https://subdomain.example.com - getting forbidden error

Following is my apache ssl virtual host file data.

<IfModule mod_ssl.c>
        <VirtualHost *:443>
                ServerAlias subdomain.example.com
                ServerName subdomain.example.com
                DocumentRoot /var/www/html/wordpress

                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined

                SSLEngine on
                SSLCertificateFile      /home/ubuntu/wordpress/cdq/my-ssl-certifications/fc1d71b08ac8aab1.crt
                SSLCertificateKeyFile /home/ubuntu/wordpress/cdq/my-ssl-certifications/host.key
                SSLCertificateChainFile /home/ubuntu/wordpress/cdq/my-ssl-certifications/gd_bundle-g2-g1.crt
<FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>
                <Directory /var/www/html/wordpress>
                        Options Indexes FollowSymLinks MultiViews
                        AllowOverride All
                        Require all granted
                </Directory>



        </VirtualHost>
</IfModule>

htaccess of wordpress project

RewriteEngine On

RewriteCond %{HTTP_HOST} subdomain.example.com$
RewriteCond %{REQUEST_URI} !^/subfolder
RewriteRule ^(.*)$ /subfolder/$1 [L] 

RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

htaccess of subfolder project

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

RewriteRule ^(.*)$ /index.php/$1 [L]

There is some permission related issue in your configuration :

<Directory /var/www/html/wordpress>
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride All
                    Require all granted
</Directory>

it require granted for all files. So all you have to do is make it like :

<Directory "/var/www/html/wordpress">
     AllowOverride All
</Directory>

PS I have modified your file and you use it like :

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
    ServerAlias subdomain.example.com
    ServerName subdomain.example.com
    DocumentRoot /var/www/html/wordpress
<Directory "/var/www/html/wordpress">
   AllowOverride All
</Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    SSLEngine on
            SSLCertificateFile      /home/ubuntu/wordpress/cdq/my-ssl-certifications/fc1d71b08ac8aab1.crt
            SSLCertificateKeyFile /home/ubuntu/wordpress/cdq/my-ssl-certifications/host.key
            SSLCertificateChainFile /home/ubuntu/wordpress/cdq/my-ssl-certifications/gd_bundle-g2-g1.crt
            <FilesMatch "\.(cgi|shtml|phtml|php)$">
                SSLOptions +StdEnvVars
            </FilesMatch>
            <Directory /usr/lib/cgi-bin>
                SSLOptions +StdEnvVars
            </Directory>
    BrowserMatch "MSIE [2-6]" \
                    nokeepalive ssl-unclean-shutdown \
                    downgrade-1.0 force-response-1.0
    BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
</VirtualHost>

There is no major change. I just modify it according to my working file. Hope it helps you.

Finally resolved the issue. Issue was with the permissions of project folder structure. Now everything is working fine

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM