简体   繁体   中英

.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:

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. 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. I am redirected to www.mywebsite.com/success.html, instead of www.mywebsite.com/success.

I have tried changing my node.js script to:

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:

nodejs equivalent of this .htaccess

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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