Tuesday, 16 May 2017

how to set good relative urls?

Here's my architecture :

  • i got a node server (Express) that provides REST services and also one EJS template
  • on my production server, an Apache server redirects all requests on a certain port to my node server
  • i got a front website. The entry point is the EJS provided by my node server. It also calls the REST services.

On my local computer, i can test my site on localhost:3000. But on production, the url is like www.mysite.com/prod

With this configuration, it fails when i call www.mysite.com/prod because it can't find stylesheets and javascripts. Indeed these ones are searched at e.g. www.mysite.com/stylesheet.css instead of www.mysite.com/prod/stylesheet.css.

To solve that, I added a line in my Apache server configuration :

RewriteRule ^/prod$ /prod/ [R,L]

But I think there's a better way to do that, as I don't want users to be obliged to go to www.mysite.com/prod/ . The final '/' has just nothing to do there !

Any solution to do that ?

(If it's not clear, feel free to ask me more details)



via MrFlo

No comments:

Post a Comment