Home >Backend Development >PHP Tutorial >Nginx configure Restful style url

Nginx configure Restful style url

WBOY
WBOYOriginal
2016-07-29 09:00:401762browse

Start SEO optimization, which of course involves fixed links. WordPress provides multiple types of link forms:

1

234567

/%year%/%monthnum%/%day% /%postname% /

/%year%/%monthnum%/%postname %/

/ %year%/%monthnum%/%day%/% postname%.html

/%year%/%monthnum%/%postname% .html

/ %category%/%postname%.html

/%post_id %.html

/%postname%/

I chose /%postname% pseudo-static. Although there seems to be no difference now, it’s time to download it. As shown below, after modifying the fixed link, a 404 error will occur when accessing the article.

Wordpress officially provides a new method to enable fixed links, which is very simple. Paste the following code into the nginx conf configuration file.

1

2

3

4

location/ {

try_files$ uri$uri//index.php?$args;

}

rewrite/wp -admin$$scheme://$host$uri/ permanent;

Then restart nginx and you can access it normally!!!

Original address: http://wanshicheng.org/nginx%E9%85%8D%E7%BD%AErestful% E9%A3%8E%E6%A0%BCurl/

The above introduces the Nginx configuration of Restful style URL, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn