首页 > 解决方案 > htaccess重定向后文件未上传

问题描述

所以文件上传最初实际上工作正常,但为了保护我的 PHP 文件,我在 htaccess 中重写了 URL,文件上传从此停止......我删除了 htaccess 重定向规则,它又开始工作了。请帮助我,因为我真的需要将实际目录隐藏到我的 PHP 文件中。

javascript ajax 请求

var form = new FormData();
form.append("file_name", file);
AJAX_REQUEST.open("POST", " https://my_site.com/testFile", true);
AJAX_REQUEST.send(form);

.htaccess 文件

RewriteEngine   On 
RewriteCond     %{HTTPS}      off
RewriteRule     ^(.*)$        https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule     ^testFile     https:///my_site.com/phps/validateFile.php    [NC,L] 

标签: phpajax.htaccessfile-upload

解决方案


RewriteRule错过了$吗?

# should this
RewriteRule     ^testFile     https:///my_site.com/phps/validateFile.php    [NC,L]

# be this?
RewriteRule     ^testFile$    https:///my_site.com/phps/validateFile.php    [NC,L]

推荐阅读