Wordpress configures the fixed url Method on linux, wordpressurl

Source: Internet
Author: User

Wordpress configures the fixed url Method on linux, wordpressurl

Wordpress fixed url setting Summary

I believe that many wordpress users will set a fixed url in the background of wordpress to improve wordpress's friendliness to search engines, or to write a blog address that is easier to remember.

But the question is, is the default wordpress url added with a domain name at first? P = id. After modification, the 404 page is displayed.

Let's get a hundred times. If you don't know, search. The result is as follows:

Find LoadModule rewrite_module modules/mod_rewrite.so in the Apache configuration file httpd. conf, remove the comment # above, and restart the server. The problem is solved.

Next let's talk about the settings under nginx. Add the following code to the nginx website configuration file.

location / {if (-f $request_filename/index.html){                rewrite (.*) $1/index.html break;        }if (-f $request_filename/index.php){                rewrite (.*) $1/index.php;        }if (!-f $request_filename){                rewrite (.*) /index.php;        }}

However, nginx on my server has a default wordpress rule file (this file cannot be used in all nginx files. Test it by yourself)

Wordpress. conf

location /blog/ {        try_files $uri $uri/ /blog/index.php?$args;}# Add trailing slash to */wp-admin requests.rewrite /blog/wp-admin$ $scheme://$host$uri/ permanent;

Introduce this wordpress. conf in the nginx website configuration file

For example,/usr/local/nginx/conf/vhost/blog. conf

Blog. conf is the website configuration file on nginx.

Add this file

include wordpress.conf;

Restart lnmp. It's still 404

The problem is that I use wordpress as the root directory, and wordpress rules should be written according to the website configuration path such as/blog folder under the root directory.

So the wordpress. conf should be changed

location / {        try_files $uri $uri/ /index.php?$args;}# Add trailing slash to */wp-admin requests.rewrite /wp-admin$ $scheme://$host$uri/ permanent;

Restart the service and solve the problem.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.