0

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)?

bolino
  • 273
  • 3
  • 12
  • 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 – djdomi Jun 23 '21 at 05:17
  • Using `rewrite` Nginx directive to rewrite URLs. What do you mean by "business related"? – bolino Jun 23 '21 at 05:29
  • `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 :-( – djdomi Jun 23 '21 at 09:02
  • 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. – bolino Jun 23 '21 at 09:26
  • 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 – djdomi Jun 23 '21 at 09:34
  • 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. – bolino Jun 23 '21 at 09:40
  • 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. – bolino Jun 23 '21 at 09:45
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/126792/discussion-between-djdomi-and-bolino). – djdomi Jun 23 '21 at 09:50
  • 1
    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. – Michael Hampton Jun 23 '21 at 11:03
  • @MichaelHampton makes sense, thanks. How should I make sure the vhosts configs are the same, and stored somewhere? In a separate repo? – bolino Jun 24 '21 at 02:35

0 Answers0