F
F
Foxwar2014-05-02 18:41:45
Nginx
Foxwar, 2014-05-02 18:41:45

How to write nginx rewrites

Need help writing nginx rewrites
There is a link http://domen.com/index.php?tag=Text
I want it to look like this:
http://domen.com/text
(the word text is constantly changing)

Answer the question

In order to leave comments, you need to log in

4 answer(s)
E
Eugene, 2014-05-02
@Nc_Soft

Why not destroy through the application?

P
Pavel Zhovner, 2014-05-02
@zhovner

Watching how nginx proxies requests.
Write what kind of cms.
location / {
try_files $uri $uri/ /index.php?$args;
}

A
Alexander N++, 2014-05-02
@sanchezzzhak

It is best to process it in puff, there is no need to make noodles out of nginx - Apache.
you can also do this
location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php; } }
In PHP, look at which URL
And if the framework is used. then everything is simple.

V
Vlad Zhivotnev, 2014-05-04
@inkvizitor68sl

Mhm. Well, your question is too broad.
Generally like this:

location =/index.php {
proxy_pass http://гдеувастамphpкрутится
...
остальные_параметры_proxy
}

location / { 
rewrite ^/(.*) /index.php?tag=$1 last; 
}

But somehow it has to be combined with something else. The same statics must not be forgotten to be described as a separate location. And if not all requests should be taxied to tag=, then this should be taken into account. And here it is not taken into account that the URI can be of the form /bla/bla/bal (it will arrive in the form of tag=bla/bla/bla)
In general, I advise you to clarify the question and write what you need in its entirety. And then they will write to you here now =)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question