特定的wordpress localhost /文件夹被重定向到https:// localhost /文件夹,其他文件夹正常工作
问题描述:
I got a freelance job of migrating a website to a new server. They only provided me with the backup files, which should be enough. While I can just upload it to the server and try to run it directly from there, I want to test it locally, because this is my standard workflow. But when I try to access \"localhost/folder\", it redirects to \"https://localhost/folder\".
It is a PHP site using a WordPress framework which I\'m not familiar with. It only happens with this specific site and on Chrome, Firefox and Edge. I\'m using WAMP as my php server on Windows 10.
I tried creating different new folders with index files, they worked normally, tried to replace the project\'s index file for a working one, tried renaming the folder, but no success.
I tried this question:
WordPress localhost not working
which was marked as a duplicate of this question:
Google Chrome redirecting localhost to https
None of them helped either.
EDIT:
Content of the .htaccess file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
#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 |
There´s also another htaccess file callde .htaccess3, not sure if it does anything or is just a backup:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# 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 |
网友观点:
Sounds to me like the site tries to force HTTPS via the .htaccess file in the root directory. Check that file - in case you can\'t see it, it\'s a hidden file, so enable those in your explorer.
Look for a line like this:
1 2 3 |
RewriteCond %{HTTPS} !=on RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L] |
Delete it, and it should fix your problem. If it doesn\'t, update your answer with the full content of the .htaccess file, so we can have a look.
1. 带 [亲测] 说明源码已经被站长亲测过!
2. 下载后的源码请在24小时内删除,仅供学习用途!
3. 分享目的仅供大家学习和交流,请不要用于商业用途!
4. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
5. 本站所有资源来源于站长上传和网络,如有侵权请邮件联系站长!
6. 没带 [亲测] 代表站长时间紧促,站长会保持每天更新 [亲测] 源码 !
7. 盗版ripro用户购买ripro美化无担保,若设置不成功/不生效我们不支持退款!
8. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
9. 如果你也有好源码或者教程,可以到审核区发布,分享有金币奖励和额外收入!
10.如果您购买了某个产品,而我们还没来得及更新,请联系站长或留言催更,谢谢理解 !
GG资源网 » 特定的wordpress localhost /文件夹被重定向到https:// localhost /文件夹,其他文件夹正常工作