【发布时间】:2019-12-27 17:03:53
【问题描述】:
我在服务器端工作,但遇到了问题。我在我的服务器中使用 XAMPP 和 Apache 服务器。首先,我购买了一个静态 IP,并打开端口供所有人访问。
我可以在以下情况下成功:“http://{StaticIP}/api/NewsJson”。但是当我尝试 "https://{StaticIP}/api/NewsJson" 时,我在浏览器中出现 403 错误。我搜索并找到了一些解决方案。
首先,我在 "xampp\apache\conf\extra\httpd-xampp" 文件夹中更改行。我更改本地授予的更改需要全部授予。
ScriptAlias /php-cgi/ "C:/xampp/php/"
<Directory "C:/xampp/php">
AllowOverride None
Options None
Require all granted
<Files "php-cgi.exe">
Require all granted
</Files>
</Directory>
<Directory "C:/xampp/cgi-bin">
<FilesMatch "\.php$">
SetHandler cgi-script
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler None
</FilesMatch>
</Directory>
<Directory "C:/xampp/htdocs/xampp">
<IfModule php7_module>
Require all granted
<Files "status.php">
php_admin_flag safe_mode off
</Files>
</IfModule>
AllowOverride AuthConfig
</Directory>
<IfModule alias_module>
Alias /licenses "C:/xampp/licenses/"
<Directory "C:/xampp/licenses">
Options +Indexes
<IfModule autoindex_color_module>
DirectoryIndexTextColor "#000000"
DirectoryIndexBGColor "#f8e8a0"
DirectoryIndexLinkColor "#bb3902"
DirectoryIndexVLinkColor "#bb3902"
DirectoryIndexALinkColor "#bb3902"
</IfModule>
Require all granted
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>
Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
<Directory "C:/xampp/phpMyAdmin">
AllowOverride AuthConfig
Require all granted
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>
Alias /webalizer "C:/xampp/webalizer/"
<Directory "C:/xampp/webalizer">
<IfModule php7_module>
<Files "webalizer.php">
php_admin_flag safe_mode off
</Files>
</IfModule>
AllowOverride AuthConfig
Require all granted
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>
</IfModule>
然后,我将这一行添加到 "xampp\apache\conf\extra\httpd-vhosts" 文件夹中。
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/api/NewsJson"
ServerName 192.168.*.** (My Server IP)
<Directory "C:/xampp/htdocs/api/NewsJson">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:443>
DocumentRoot "C:/xampp/htdocs/api/NewsJson"
ServerName 192.168.*.** (My Server IP)
<Directory "C:/xampp/htdocs/api/NewsJson">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:443>
DocumentRoot "C:/xampp/htdocs/api/NewsJson"
ServerName 192.168.*.** (My Server IP)
SSLEngine on
SSLCertificateFile "C:/xampp/apache/conf/ssl.crt/server.crt"
SSLCertificateKeyFile "C:/xampp/apache/conf/ssl.key/server.key"
</VirtualHost>
我更改了我的 ".htaccess" 文件夹。
RewriteEngine On
RewriteRule NewsJson.html$ NewsJson.php [L]
当我更改它们时,我关闭了 Apache 并再次打开。但是,我仍然采取 403 禁止错误。我该如何解决这个问题?
AH00112: Warning: DocumentRoot [C:/xampp/htdocs/api/NewsJson] does not exist
AH00112: Warning: DocumentRoot [C:/xampp/htdocs/api/NewsJson] does not exist
[Thu Aug 22 14:47:29.161955 2019] [ssl:warn] [pid 5332:tid 384] AH01909: StaticIP:80:0 server certificate does NOT include an ID which matches the server name
[Thu Aug 22 14:47:29.161955 2019] [ssl:warn] [pid 5332:tid 384] AH01915: Init: (StaticIP:80) You configured HTTPS(443) on the standard HTTP(80) port!
【问题讨论】:
标签: apache xampp http-status-code-403