Remove .php make friendly urls



I have a VPS running with nginx and I’m having trouble figuring out how to configure the server so I can have friendly urls:

instead of index.php … have this: /
or instead of contact.php … have this: /contact/ etc etc

Also being able to do this with sub directories too.

I read through this:

but still am unsure.

First Question:

  • Where does the new configuration go? and what is the name of it? It seems like it would go here: /home/YOURUSER/nginx/YOURDOMAIN.COM/*

What is the file called? nginx.conf or can it be called anything?

Does the server automatically load anything with a .conf?

If someone has this figured out already, it would be greatly appreciated.


Correct. You’ll need to create the directories “nginx” and “” if they don’t exist already; they’re not created automatically.

Any file in the directory at all is included, actually. The directive in the server configuration looks like:

Note that, if you’ve created or changed any configuration files in there, you’ll need to get nginx to restart to make it pick up the changes. From a VPS admin user, run “sudo /etc/init.d/nginx restart”.

As far as how to make “friendly URLs”, that’ll depend on your application and how it dispatches requests. There are a few examples on the DreamHost wiki which you may be able to draw inspiration from: