仅在https上禁止403错误,但是网址http工作正常

时间:2017-07-26 11:18:26

标签: codeigniter ssl amazon-ec2 http-status-code-403 apache2.4

在我的服务器上我将word上的wordpress站点和codeigniter项目作为wordpress中的子文件夹,我为codeigniter项目创建了子域。两者都没有SSL工作正常现在我想在子域项目上应用SSL,同时在这个问题上应用ssl我面临的问题。当我使用https://subdomain.example.com打开网站时,它会给我禁止的403错误。

以下是我在apache上托管的网站的示例。我有我的root wordpress项目的符号链接。

http://example.com - 工作正常 - 在root上的wordpress项目

http://subdomain.example.com - 工作正常 - wordpress项目文件夹下的codeigniter项目

https://subdomain.example.com - 获取禁止错误

以下是我的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>

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

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]

2 个答案:

答案 0 :(得分:2)

您的配置中存在一些与权限相关的问题:

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

它需要授予所有文件。所以你要做的就是像:

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

P.S。 我修改了您的文件并将其用作:

<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>

没有重大变化。我只是根据我的工作文件修改它。希望它可以帮到你。

答案 1 :(得分:2)

终于解决了这个问题。问题在于项目文件夹结构的权限。现在一切正常了