Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 无法将http重定向到https_Apache - Fatal编程技术网

Apache 无法将http重定向到https

Apache 无法将http重定向到https,apache,Apache,我无法将我的http流量重定向到https,因此可以使用http和https访问我的站点,但我只希望通过https访问它。位于/var/apps/web/中的My.htaccess文件如下所示: RewriteEngine On RewriteCond %{SERVER_PORT} !443 RewriteRule ^(/(.*))?$ https://%{HTTP_HOST}/$1 [R=301,L] 我已经编辑了apache2.conf并添加了以下配置: <Directory /va

我无法将我的http流量重定向到https,因此可以使用http和https访问我的站点,但我只希望通过https访问它。位于/var/apps/web/中的My.htaccess文件如下所示:

RewriteEngine On
RewriteCond %{SERVER_PORT} !443
RewriteRule ^(/(.*))?$ https://%{HTTP_HOST}/$1 [R=301,L]
我已经编辑了apache2.conf并添加了以下配置:

<Directory /var/mode/cci/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
</Directory>

选项索引跟随符号链接
允许超越所有
命令允许,拒绝
通融
我的文档根目录位于/etc/apache2/sites available,如下所示:

<VirtualHost *:7777>
        ServerAdmin webmaster@localhost
        ServerName mydomain.co/
        DocumentRoot /var/apps/web/
        Header always append X-Frame-Options SAMEORIGIN
        Header always set X-XSS-Protection "1; mode=block"
        Header always unset Server
        Header always set X-Content-Type-Options nosniff
        <Directory />
                Options -Indexes -FollowSymLinks -MultiViews
                AllowOverride None
        </Directory>
        <Directory /var/apps/web/>
                LimitRequestBody 512000
                Options -Indexes -FollowSymLinks -MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -Indexes -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
        TraceEnable off

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:443>
        ServerAdmin webmaster@localhost
        ServerName mydomain.co/
        DocumentRoot /var/apps/web/
        Header always append X-Frame-Options SAMEORIGIN
        Header always set X-XSS-Protection "1; mode=block"
        Header always unset Server
        Header always set X-Content-Type-Options nosniff
        <Directory />
                Options -Indexes -FollowSymLinks -MultiViews
                AllowOverride None
 </Directory>
        <Directory /var/apps/web/>
                LimitRequestBody 512000
                Options -Indexes -FollowSymLinks -MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -Indexes -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>
         SSLEngine on
        SSLCertificateFile /etc/apache2/ssl/apache.crt
        SSLCertificateKeyFile /etc/apache2/ssl/apache.key

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
        TraceEnable off

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

服务器管理员webmaster@localhost
ServerName mydomain.co/
DocumentRoot/var/apps/web/
标题始终附加X-Frame-Options SAMEORIGIN
标头始终设置X-XSS-Protection“1;模式=块”
标头始终未设置服务器
标题始终设置X-Content-Type-Options nosniff
选项-索引-跟随符号链接-多视图
不允许超限
莱姆博迪512000
选项-索引-跟随符号链接-多视图
不允许超限
命令允许,拒绝
通融
ScriptAlias/cgi-bin//usr/lib/cgi-bin/
不允许超限
选项+执行CGI-索引-多视图+符号链接所有者匹配
命令允许,拒绝
通融
ErrorLog${APACHE_LOG_DIR}/error.LOG
#可能的值包括:调试、信息、通知、警告、错误、临界值、,
#警惕,埃默格。
日志级别警告
可追溯的
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
服务器管理员webmaster@localhost
ServerName mydomain.co/
DocumentRoot/var/apps/web/
标题始终附加X-Frame-Options SAMEORIGIN
标头始终设置X-XSS-Protection“1;模式=块”
标头始终未设置服务器
标题始终设置X-Content-Type-Options nosniff
选项-索引-跟随符号链接-多视图
不允许超限
莱姆博迪512000
选项-索引-跟随符号链接-多视图
不允许超限
命令允许,拒绝
通融
ScriptAlias/cgi-bin//usr/lib/cgi-bin/
不允许超限
选项+执行CGI-索引-多视图+符号链接所有者匹配
命令允许,拒绝
通融
斯伦金安
SSLCertificateFile/etc/apache2/ssl/apache.crt
SSLCertificateKeyFile/etc/apache2/ssl/apache.key
ErrorLog${APACHE_LOG_DIR}/error.LOG
#可能的值包括:调试、信息、通知、警告、错误、临界值、,
#警惕,埃默格。
日志级别警告
可追溯的
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合

请帮忙

可能重复:我想确认我的文档根目录和apache2.conf配置文件是否正确?如果您的htaccess文件有效,您只需要将这些说明放在您的文件中。我如何确认它有效?htaccess文件位于/var/apps/web文件夹中,这是有效位置吗?确定,.htaccess文件必须位于文档的根目录中。不要重命名该文件,只是在该文件中出错