htaccess重定向后文件无法上传

时间:2018-06-17 03:08:46

标签: php ajax .htaccess file-upload

所以文件上传实际上最初工作正常,但是为了保护我的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] 

1 个答案:

答案 0 :(得分:0)

您的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]