特定 wordpress localhost/folder 被重定向到 https://localhost/folder,其他文件夹正常工作

Specific wordpress localhost/folder being redirected to https://localhost/folder, other folders work normally

我找到了一份将网站迁移到新服务器的自由职业。他们只给我提供了备份文件,这应该足够了。虽然我可以将它上传到服务器并尝试直接从那里 运行 它,但我想在本地测试它,因为这是我的标准工作流程。但是当我尝试访问 "localhost/folder" 时,它会重定向到 "https://localhost/folder".

这是一个使用我不熟悉的 Wordpress 框架的 PHP 网站。它只发生在这个特定站点和 Chrome、Firefox 和 Edge 上。我在 Windows 10.

上使用 WAMP 作为我的 php 服务器

我尝试用索引文件创建不同的新文件夹,它们工作正常,尝试用一个工作文件替换项目的索引文件,尝试重命名文件夹,但没有成功。

我试过这个问题: Wordpress localhost not working

被标记为与此问题重复:

None 他们中的任何一个都提供了帮助。

编辑: .htaccess 文件的内容

#Options +FollowSymlinks
#Header add X-Frame-Options "DENY"
#Header add X-XSS-Protection "1; mode=block"
#Header add X-Content-Type-Options "nosniff"
#Header unset link
#Header unset Server
#Header unset X-Pingback
#ServerSignature Off
# HTTPS forced by SG-Optimizer
<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteCond %{HTTPS} off
   RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
</IfModule>
# END HTTPS
# BEGIN WordPress
<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /
   RewriteRule ^index\.php$ - [L]
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule . /index.php [L]
</IfModule>
# END WordPress
<IfModule mod_expires.c>
   ExpiresActive On
   # Images
   ExpiresByType image/jpeg "access plus 1 year"
   ExpiresByType image/gif "access plus 1 year"
   ExpiresByType image/png "access plus 1 year"
   ExpiresByType image/webp "access plus 1 year"
   ExpiresByType image/svg+xml "access plus 1 year"
   ExpiresByType image/x-icon "access plus 1 year"
   # Video
   ExpiresByType video/mp4 "access plus 1 year"
   ExpiresByType video/mpeg "access plus 1 year"
   # CSS, JavaScript
   ExpiresByType text/css "access plus 1 month"
   ExpiresByType text/javascript "access plus 1 month"
   ExpiresByType application/javascript "access plus 1 month"
   # Others
   ExpiresByType application/pdf "access plus 1 month"
   ExpiresByType application/x-shockwave-flash "access plus 1 month"
</IfModule>
<IfModule mod_deflate.c>
   SetOutputFilter DEFLATE
   <IfModule mod_setenvif.c>
      <IfModule mod_headers.c>
         SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
         RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
      </IfModule>
   </IfModule>
   <IfModule mod_filter.c>
      AddOutputFilterByType DEFLATE "application/atom+xml" \
      "application/javascript" \
      "application/json" \
      "application/ld+json" \
      "application/manifest+json" \
      "application/rdf+xml" \
      "application/rss+xml" \
      "application/schema+json" \
      "application/vnd.geo+json" \
      "application/vnd.ms-fontobject" \
      "application/x-font-ttf" \
      "application/x-font-opentype" \
      "application/x-font-truetype" \
      "application/x-javascript" \
      "application/x-web-app-manifest+json" \
      "application/xhtml+xml" \
      "application/xml" \
      "font/eot" \
      "font/opentype" \
      "font/otf" \
      "image/bmp" \
      "image/svg+xml" \
      "image/vnd.microsoft.icon" \
      "image/x-icon" \
      "text/cache-manifest" \
      "text/css" \
      "text/html" \
      "text/javascript" \
      "text/plain" \
      "text/vcard" \
      "text/vnd.rim.location.xloc" \
      "text/vtt" \
      "text/x-component" \
      "text/x-cross-domain-policy" \
      "text/xml"
   </IfModule>
   <IfModule mod_mime.c>
      AddEncoding gzip              svgz
   </IfModule>
</IfModule>
# Wordfence WAF
<Files ".user.ini">
   <IfModule mod_authz_core.c>
      Require all denied
   </IfModule>
   <IfModule !mod_authz_core.c>
      Order deny,allow
      Deny from all
   </IfModule>
</Files>
# END Wordfence WAF
# START XML RPC BLOCKING
<Files xmlrpc.php>
   Order Deny,Allow
   Deny from all
</Files>
# FINISH XML RPC BLOCKING
<files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</files>
<files wp-config.php>
   order allow,deny
   deny from all
</files>
# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php7_module>
   php_flag display_errors Off
   php_value max_execution_time 30
   php_value max_input_time 30
   php_value max_input_vars 1000
   php_value memory_limit 128M
   php_value post_max_size 10M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php72"
   php_value upload_max_filesize 10M
   php_flag zlib.output_compression On
</IfModule>
# END cPanel-generated php ini directives, do not edit

还有另一个 htaccess 文件 callde .htaccess3,不确定它是否有任何作用或只是一个备份:

# php -- BEGIN cPanel-generated handler, do not edit
# NOTE this account's php is controlled via FPM and the vhost, this is a place holder.
# Do not edit. This next line is to support the cPanel php wrapper (php_cli).
# AddType application/x-httpd-ea-php72 .php .phtml
# php -- END cPanel-generated handler, do not edit

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php7_module>
   php_flag display_errors Off
   php_value max_execution_time 30
   php_value max_input_time 30
   php_value max_input_vars 1000
   php_value memory_limit 128M
   php_value post_max_size 10M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php72"
   php_value upload_max_filesize 10M
   php_flag zlib.output_compression On
</IfModule>
# END cPanel-generated php ini directives, do not edit

在我看来,该网站试图通过根目录中的 .htaccess 文件强制使用 HTTPS。检查该文件 - 如果您看不到它,则它是一个隐藏文件,因此请在您的资源管理器中启用它们。

寻找这样一行:

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{SERVER_NAME}/ [R,L]

删除它,它应该可以解决您的问题。如果没有,请使用 .htaccess 文件的完整内容更新您的答案,以便我们查看。