How to solve rewrite in ngnix

Since i bought the vps with ngnix environment, i’m new about it.When i upload my site to the host, i can’t use the rewrite module.
The case is that, i am unable to use linux command and also vim,so i have to learn to deal with it.Finally i find that the rewrite sentences in apache rewrite and ngnix are difference, i change the commands.

The rewrite commands in apache rewrite are:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^.*(.css|.js|.gif|.png|.jpg|.jpeg)$

but in ngnix are:

if  (!-e $request_filename)
{
    rewrite ^(.*)$ /index.php;
}

And here is the command to restart the ngnix service:

/usr/local/nginx/sbin/nginx -s reload

The location of the vhost.conf is ‘/usr/local/nginx/conf/vhost.conf’;
Just modify it and restart the service. I think there is another way to use apache rewrite file in ngnix, if i find out it , i will memory it below.

There is one article about how to exchange apache rewrite commands to ngnix commands:
http://edu.codepub.com/2010/0829/25477.php, hope it is also useful to you.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

WordPress SEO fine-tune by Meta SEO Pack from Poradnik Webmastera