php - Rewrite URLs with NGINX -
i running on nginx , trying create blog works this:
- i create new post title "how create new website" under "business" category
- i turn title slug how-to-create-a-new-website
- 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
Post a Comment