【问题标题】:.htaccess file won't work on my node.js app.htaccess 文件在我的 node.js 应用程序上不起作用
【发布时间】:2018-06-13 17:35:26
【问题描述】:

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

我的网站在 www.mywebsite.com 运行。提交表单时,页面被重定向到成功页面:

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

问题是,我的 .htaccess 文件无法正常工作。我被重定向到 www.mywebsite.com/success.html,而不是 www.mywebsite.com/success。

我尝试将我的 node.js 脚本更改为:

res.redirect("/success");

然后我得到一个错误页面。我做错了什么?

【问题讨论】:

  • .htaccess 仅适用于 apache 服务器,不适用于节点
  • 那么,是否有解决方法/其他方法来实现这一目标?

标签: javascript php node.js .htaccess


【解决方案1】:

.htaccess 仅适用于 Apache 服务器,但您可以尝试以下方式:

nodejs equivalent of this .htaccess

【讨论】:

    猜你喜欢
    • 2011-08-09
    • 1970-01-01
    • 2016-05-29
    • 2013-12-16
    • 1970-01-01
    • 1970-01-01
    • 2015-02-23
    • 2017-09-01
    相关资源
    最近更新 更多