Node.js show the index page instead of the request page2019 Community Moderator ElectionHow do I debug Node.js applications?How do I get started with Node.jsWriting files in Node.jsHow do I pass command line arguments to a Node.js program?Check synchronously if file/directory exists in Node.jsRead environment variables in Node.jsHow to decide when to use Node.js?How to exit in Node.jsWhat is the purpose of Node.js module.exports and how do you use it?How is an HTTP POST request made in node.js?
Welcoming 2019 Pi day: How to draw the letter π?
 
 Why doesn't the EU now just force the UK to choose between referendum and no-deal?
 
 Why doesn't using two cd commands in bash script execute the second command?
 
 Replacing Windows 7 security updates with anti-virus?
 
 Unreachable code, but reachable with exception
 
 Current sense amp + op-amp buffer + ADC: Measuring down to 0 with single supply
 
 Ban on all campaign finance?
 
 What options are left, if Britain cannot decide?
 
 Define, (actually define) the "stability" and "energy" of a compound
 
 Why do Australian milk farmers need to protest supermarkets' milk price?
 
 Meaning of "SEVERA INDEOVI VAS" from 3rd Century slab
 
 Does this property of comaximal ideals always holds?
 
 Happy pi day, everyone!
 
 Theorems like the Lovász Local Lemma?
 
 An Accountant Seeks the Help of a Mathematician
 
 Distribution of Maximum Likelihood Estimator
 
 Life insurance that covers only simultaneous/dual deaths
 
 Will a pinhole camera work with instant film?
 
 It's a yearly task, alright
 
 2D counterpart of std::array in C++17
 
 How can I change step-down my variable input voltage? [Microcontroller]
 
 The use of "touch" and "touch on" in context
 
 Instead of Universal Basic Income, why not Universal Basic NEEDS?
 
 Science-fiction short story where space navy wanted hospital ships and settlers had guns mounted everywhere
Node.js show the index page instead of the request page
2019 Community Moderator ElectionHow do I debug Node.js applications?How do I get started with Node.jsWriting files in Node.jsHow do I pass command line arguments to a Node.js program?Check synchronously if file/directory exists in Node.jsRead environment variables in Node.jsHow to decide when to use Node.js?How to exit in Node.jsWhat is the purpose of Node.js module.exports and how do you use it?How is an HTTP POST request made in node.js?
I start to use Node.js for a while, so I try to use .htaccess file to clean the urls and its not worked, so I found that we can use express-http-proxy plugin in app.use function. so - I build a login page (based on php) and when I redirect to this page the page was shown is the index.html page, here`s my code:
var http = require('http');
var proxy = require('express-http-proxy');
app.use(express.static('../public'));
app.use('/login', proxy('http://localhost:1234/pages/login.php'));
Solution for this problem:
I changed the url in proxy to my website address, instead of the server address (with port 1234). for example if my server run on localhost:1234, on domain domain.com you need to put this domain.com in the proxy.
node.js .htaccess
add a comment |
I start to use Node.js for a while, so I try to use .htaccess file to clean the urls and its not worked, so I found that we can use express-http-proxy plugin in app.use function. so - I build a login page (based on php) and when I redirect to this page the page was shown is the index.html page, here`s my code:
var http = require('http');
var proxy = require('express-http-proxy');
app.use(express.static('../public'));
app.use('/login', proxy('http://localhost:1234/pages/login.php'));
Solution for this problem:
I changed the url in proxy to my website address, instead of the server address (with port 1234). for example if my server run on localhost:1234, on domain domain.com you need to put this domain.com in the proxy.
node.js .htaccess
 
 
 
 
 
 
 
 please someone can help me?
 
 – Amanda White
 Mar 7 at 5:01
 
 
 
add a comment |
I start to use Node.js for a while, so I try to use .htaccess file to clean the urls and its not worked, so I found that we can use express-http-proxy plugin in app.use function. so - I build a login page (based on php) and when I redirect to this page the page was shown is the index.html page, here`s my code:
var http = require('http');
var proxy = require('express-http-proxy');
app.use(express.static('../public'));
app.use('/login', proxy('http://localhost:1234/pages/login.php'));
Solution for this problem:
I changed the url in proxy to my website address, instead of the server address (with port 1234). for example if my server run on localhost:1234, on domain domain.com you need to put this domain.com in the proxy.
node.js .htaccess
I start to use Node.js for a while, so I try to use .htaccess file to clean the urls and its not worked, so I found that we can use express-http-proxy plugin in app.use function. so - I build a login page (based on php) and when I redirect to this page the page was shown is the index.html page, here`s my code:
var http = require('http');
var proxy = require('express-http-proxy');
app.use(express.static('../public'));
app.use('/login', proxy('http://localhost:1234/pages/login.php'));
Solution for this problem:
I changed the url in proxy to my website address, instead of the server address (with port 1234). for example if my server run on localhost:1234, on domain domain.com you need to put this domain.com in the proxy.
node.js .htaccess
node.js .htaccess
edited Mar 8 at 4:54
Amanda White
asked Mar 6 at 18:59
Amanda WhiteAmanda White
195
195
 
 
 
 
 
 
 
 please someone can help me?
 
 – Amanda White
 Mar 7 at 5:01
 
 
 
add a comment |
 
 
 
 
 
 
 
 please someone can help me?
 
 – Amanda White
 Mar 7 at 5:01
 
 
 
please someone can help me?
– Amanda White
Mar 7 at 5:01
please someone can help me?
– Amanda White
Mar 7 at 5:01
add a comment |
 1 Answer
 1
 
active
oldest
votes
As far as I know Node does not use htaccess. You could look into express-htaccess-middleware to see if you can proxy your php page through your Node server. I don't know if it can be done though.
Anyway it seems that you're trying to render a local php page through Node/Express (.../pages/login.php). Node only does javascript so it won't be able to render a php page, there is an express middleware that does php interpretation (provided php is installed on your server) but I won't advise you to do that.
If you want to serve php pages, it's better to have them hosted on a php server, then if you want to create a proxy from your node to the php server, what I would do is a proxy in express to your php server with express-http-proxy
 app.use(express.static('../public'));
 app.use('/login', proxy('www.domainOfYourPhpServer/pages/login.php'));
 
 
 
 
 
 
 
 When I do this I got this error:- Error: getaddrinfo ENOTFOUND locahost locahost:1234 at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
 
 – Amanda White
 Mar 7 at 14:03
 
 
 
 
 
 
 
 
 
 
 
 Ok so now I see my problem, I wrote- locahostinstead of- localhost, but its not work.. when I go to- /loginits show me the index.html page..
 
 – Amanda White
 Mar 7 at 15:56
 
 
 
 
 
 
 
 
 
 
 Can you update your question with your last attemps to help with the resolution?
 
 – remix23
 Mar 7 at 16:02
 
 
 
 
 
 
 
 
 
 
 yes sure, please see the edit.
 
 – Amanda White
 Mar 7 at 16:56
 
 
 
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55030375%2fnode-js-show-the-index-page-instead-of-the-request-page%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
 1 Answer
 1
 
active
oldest
votes
 1 Answer
 1
 
active
oldest
votes
active
oldest
votes
active
oldest
votes
As far as I know Node does not use htaccess. You could look into express-htaccess-middleware to see if you can proxy your php page through your Node server. I don't know if it can be done though.
Anyway it seems that you're trying to render a local php page through Node/Express (.../pages/login.php). Node only does javascript so it won't be able to render a php page, there is an express middleware that does php interpretation (provided php is installed on your server) but I won't advise you to do that.
If you want to serve php pages, it's better to have them hosted on a php server, then if you want to create a proxy from your node to the php server, what I would do is a proxy in express to your php server with express-http-proxy
 app.use(express.static('../public'));
 app.use('/login', proxy('www.domainOfYourPhpServer/pages/login.php'));
 
 
 
 
 
 
 
 When I do this I got this error:- Error: getaddrinfo ENOTFOUND locahost locahost:1234 at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
 
 – Amanda White
 Mar 7 at 14:03
 
 
 
 
 
 
 
 
 
 
 
 Ok so now I see my problem, I wrote- locahostinstead of- localhost, but its not work.. when I go to- /loginits show me the index.html page..
 
 – Amanda White
 Mar 7 at 15:56
 
 
 
 
 
 
 
 
 
 
 Can you update your question with your last attemps to help with the resolution?
 
 – remix23
 Mar 7 at 16:02
 
 
 
 
 
 
 
 
 
 
 yes sure, please see the edit.
 
 – Amanda White
 Mar 7 at 16:56
 
 
 
add a comment |
As far as I know Node does not use htaccess. You could look into express-htaccess-middleware to see if you can proxy your php page through your Node server. I don't know if it can be done though.
Anyway it seems that you're trying to render a local php page through Node/Express (.../pages/login.php). Node only does javascript so it won't be able to render a php page, there is an express middleware that does php interpretation (provided php is installed on your server) but I won't advise you to do that.
If you want to serve php pages, it's better to have them hosted on a php server, then if you want to create a proxy from your node to the php server, what I would do is a proxy in express to your php server with express-http-proxy
 app.use(express.static('../public'));
 app.use('/login', proxy('www.domainOfYourPhpServer/pages/login.php'));
 
 
 
 
 
 
 
 When I do this I got this error:- Error: getaddrinfo ENOTFOUND locahost locahost:1234 at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
 
 – Amanda White
 Mar 7 at 14:03
 
 
 
 
 
 
 
 
 
 
 
 Ok so now I see my problem, I wrote- locahostinstead of- localhost, but its not work.. when I go to- /loginits show me the index.html page..
 
 – Amanda White
 Mar 7 at 15:56
 
 
 
 
 
 
 
 
 
 
 Can you update your question with your last attemps to help with the resolution?
 
 – remix23
 Mar 7 at 16:02
 
 
 
 
 
 
 
 
 
 
 yes sure, please see the edit.
 
 – Amanda White
 Mar 7 at 16:56
 
 
 
add a comment |
As far as I know Node does not use htaccess. You could look into express-htaccess-middleware to see if you can proxy your php page through your Node server. I don't know if it can be done though.
Anyway it seems that you're trying to render a local php page through Node/Express (.../pages/login.php). Node only does javascript so it won't be able to render a php page, there is an express middleware that does php interpretation (provided php is installed on your server) but I won't advise you to do that.
If you want to serve php pages, it's better to have them hosted on a php server, then if you want to create a proxy from your node to the php server, what I would do is a proxy in express to your php server with express-http-proxy
 app.use(express.static('../public'));
 app.use('/login', proxy('www.domainOfYourPhpServer/pages/login.php'));
As far as I know Node does not use htaccess. You could look into express-htaccess-middleware to see if you can proxy your php page through your Node server. I don't know if it can be done though.
Anyway it seems that you're trying to render a local php page through Node/Express (.../pages/login.php). Node only does javascript so it won't be able to render a php page, there is an express middleware that does php interpretation (provided php is installed on your server) but I won't advise you to do that.
If you want to serve php pages, it's better to have them hosted on a php server, then if you want to create a proxy from your node to the php server, what I would do is a proxy in express to your php server with express-http-proxy
 app.use(express.static('../public'));
 app.use('/login', proxy('www.domainOfYourPhpServer/pages/login.php'));
answered Mar 7 at 10:21
remix23remix23
1,069312
1,069312
 
 
 
 
 
 
 
 When I do this I got this error:- Error: getaddrinfo ENOTFOUND locahost locahost:1234 at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
 
 – Amanda White
 Mar 7 at 14:03
 
 
 
 
 
 
 
 
 
 
 
 Ok so now I see my problem, I wrote- locahostinstead of- localhost, but its not work.. when I go to- /loginits show me the index.html page..
 
 – Amanda White
 Mar 7 at 15:56
 
 
 
 
 
 
 
 
 
 
 Can you update your question with your last attemps to help with the resolution?
 
 – remix23
 Mar 7 at 16:02
 
 
 
 
 
 
 
 
 
 
 yes sure, please see the edit.
 
 – Amanda White
 Mar 7 at 16:56
 
 
 
add a comment |
 
 
 
 
 
 
 
 When I do this I got this error:- Error: getaddrinfo ENOTFOUND locahost locahost:1234 at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
 
 – Amanda White
 Mar 7 at 14:03
 
 
 
 
 
 
 
 
 
 
 
 Ok so now I see my problem, I wrote- locahostinstead of- localhost, but its not work.. when I go to- /loginits show me the index.html page..
 
 – Amanda White
 Mar 7 at 15:56
 
 
 
 
 
 
 
 
 
 
 Can you update your question with your last attemps to help with the resolution?
 
 – remix23
 Mar 7 at 16:02
 
 
 
 
 
 
 
 
 
 
 yes sure, please see the edit.
 
 – Amanda White
 Mar 7 at 16:56
 
 
 
When I do this I got this error:
Error: getaddrinfo ENOTFOUND locahost locahost:1234 at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)– Amanda White
Mar 7 at 14:03
When I do this I got this error:
Error: getaddrinfo ENOTFOUND locahost locahost:1234 at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)– Amanda White
Mar 7 at 14:03
Ok so now I see my problem, I wrote
locahost instead of localhost, but its not work.. when I go to /login its show me the index.html page..– Amanda White
Mar 7 at 15:56
Ok so now I see my problem, I wrote
locahost instead of localhost, but its not work.. when I go to /login its show me the index.html page..– Amanda White
Mar 7 at 15:56
Can you update your question with your last attemps to help with the resolution?
– remix23
Mar 7 at 16:02
Can you update your question with your last attemps to help with the resolution?
– remix23
Mar 7 at 16:02
yes sure, please see the edit.
– Amanda White
Mar 7 at 16:56
yes sure, please see the edit.
– Amanda White
Mar 7 at 16:56
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55030375%2fnode-js-show-the-index-page-instead-of-the-request-page%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
please someone can help me?
– Amanda White
Mar 7 at 5:01