Score:0

Best software and practices on how to test a static website locally with URL rewrites

in flag

I recently switched from Apache to Nginx on my production server.

My websites have internal links URLs that are rewritten. When I was using Apache, my URL rewrite rules for my websites (HTML/CSS/PHP/JS) were in .htaccess files in the websites repos/folders, thus I was able to test the websites locally with MAMP.

Now that I switched to Nginx, the rewrite rules now reside in Nginx vhost conf files (using rewrite directive) on my production server, and my local MAMP does not provide an option to mimic the rewrite rules locally, so pages urls are not rewritten (thus internal links don't work).

Any local server software / best practice on how to solve that while keeping my local stack simple (it's for small/ non critical websites)?

djdomi avatar
za flag
You can use a Public Converter to insert it into the config file of your domain, to do it easy - but your missing precise information what you are doing here and if its Business related is also a other part of question
in flag
Using `rewrite` Nginx directive to rewrite URLs. What do you mean by "business related"?
djdomi avatar
za flag
`Questions on Server Fault must be about managing information technology systems in a business environment. Home and end-user computing questions may be asked on Super User, and questions about development, testing and development tools may be asked on Stack Overflow.` In fact, in don't see this relevance here. You still do only tell "that's problem X, I want to Solve Y" - please either show your files which are affected by the change of your question (edit) or please close this question as you are not willing to provide necessary information :-(
in flag
The question is related to a business server in a local business testing environnement. Any kind of URL rewriting is concerned in my question. An example of Nginx rewrite directive would be rewrite `^/([a-zA-Z0-9-]+)$ /$1.php last;` in any vhost Nginx conf file, for a simple regex one, for example. But again the question applies to any URL rewrite directive done by the web server, wether it's done in a vhost or in a general web server conf file, and wether the web server is Nginx, Apache, or any local testing web server that would permit it locally in a simple way.
djdomi avatar
za flag
Would you as already pleased, show us the htaccess that we can continue? the simple way would be, installed a apache on a second sever, in case on a lan, use nginx as reverse proxy handle the rest and contact any lan targets
in flag
There is no .htaccess file, as I said I switched to Nginx. I'm asking about what local web server that manages URL rewriting to run locally the same way as production. No need for reverse proxy or a second server, as the production doesn't run any of those.
in flag
I guess then the simpler way would be to use Apache locally, recreate the .htaccess files, and gitgnore them in production. I would have prefer using Nginx as well locally though. I was wondering if some other folks have better local testing settings for the same (very common) case.
djdomi avatar
za flag
Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/126792/discussion-between-djdomi-and-bolino).
Michael Hampton avatar
cz flag
Dump MAMP and use nginx locally (or better, in a Linux VM). On a side note: when doing web development on macOS you should use a case sensitive filesystem to store the web documents to avoid a variety of other problems.
in flag
@MichaelHampton makes sense, thanks. How should I make sure the vhosts configs are the same, and stored somewhere? In a separate repo?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.