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

时间:2019-07-03 20:56:23

标签: php wordpress migration localhost wamp

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

这是一个使用Wordpress框架的PHP网站,我不熟悉。仅在此特定网站以及Chrome,Firefox和Edge上才发生这种情况。我将WAMP用作Windows 10上的php服务器。

我尝试用索引文件创建其他新文件夹,它们正常工作,尝试将项目的索引文件替换为可用的索引文件,尝试重命名该文件夹,但未成功。

我尝试了以下问题: Wordpress localhost not working

被标记为该问题的重复: Google Chrome redirecting localhost to https

他们都没有帮助。

编辑: .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文件,称为.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

1 个答案:

答案 0 :(得分:0)

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

寻找这样的一行:

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

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