php - Rewrite URLs with NGINX -




i running on nginx , trying create blog works this:

  1. i create new post title "how create new website" under "business" category
  2. i turn title slug how-to-create-a-new-website
  3. the final url looks this: http:://www.example.com/blog/business/how-to-create-a-new-website

so trying accomplish this:

i have single page searches category , slug in database. retrieves article , displays it. category , slug should able anything.

so need nginx rewrite/location rule allow this. have done similar on server apache rewrite rule in .htaccess file (but without category):

#clean urls blog rewriterule ^blog/(.*)$ blog/article.php?slug=$1 [l] 

everything have tried on nginx server not seem work. appreciated!

you can try rule:

location ~ /blog/ {    rewrite "^(/blog)/([\w-]+)/([\w-]+)/?$" $1/article.php?category=$2&slug=$3 last; } 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -