简体   繁体   English

.htaccess文件在我的node.js应用程序上不起作用

[英].htaccess file won't work on my node.js app

I have the following .htaccess file located in the root directory of my node.js app: 我的node.js应用程序的根目录中有以下.htaccess文件:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
RewriteRule ^(.*)\.html$ /$1 [R=301,L]

My website runs at www.mywebsite.com. 我的网站在www.mywebsite.com上运行。 When a form is submitted, the page is redirected to a success page: 提交表单后,页面将重定向到成功页面:

res.redirect("/success.html");

The problem is, my .htaccess file isn't working properly. 问题是,我的.htaccess文件无法正常工作。 I am redirected to www.mywebsite.com/success.html, instead of www.mywebsite.com/success. 我被重定向到www.mywebsite.com/success.html,而不是www.mywebsite.com/success。

I have tried changing my node.js script to: 我尝试将node.js脚本更改为:

res.redirect("/success");

But then I get an error page. 但是然后我得到一个错误页面。 What am I doing wrong? 我究竟做错了什么?

.htaccess is only for Apache servers, but you can try something like this: .htaccess仅适用于Apache服务器,但是您可以尝试执行以下操作:

nodejs equivalent of this .htaccess 相当于此.htaccess的nodejs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM