简体   繁体   English

仅在https上获得禁止403错误,但url http正常运行

[英]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. 在我的服务器上,我在root和codeigniter项目上有wordpress网站,作为wordpress中的子文件夹,并为codeigniter项目创建了子域。 Both are working fine without SSL Now I want to apply SSL on subdomain project while applying ssl on this I am facing issue. 两者都可以在没有SSL的情况下正常工作。现在,我想在子域项目上应用SSL,同时在此上使用ssl,这是我面临的问题。 When I am opening site by using https://subdomain.example.com it is giving me forbidden 403 error. 当我使用https://subdomain.example.com打开网站时,出现了403错误。

Following is the example of my sites hosted on apache. 以下是我在apache上托管的网站的示例。 I had symbolic link for my root wordpress project. 我的根wordpress项目有符号链接。

http://example.com - working fine - wordpress project on root http://example.com-运行正常-root上的wordpress项目

http://subdomain.example.com - working fine - codeigniter project under wordpress project folder http ://subdomain.example.com-运行正常-Wordpress项目文件夹下的Codeigniter项目

https://subdomain.example.com - getting forbidden error https ://subdomain.example.com-遭到禁止的错误

Following is my apache ssl virtual host file data. 以下是我的Apache SSL虚拟主机文件数据。

<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 WordPress项目的htaccess

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 子文件夹项目的htaccess

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 : PS 我已经修改了您的文件,您可以像这样使用它:

<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 现在一切正常

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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