Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to remove index.php from wordpress

Shulou Source: shulou.com Published: 2022-06-02 00:20:59 09月15日 Update

Editor to share with you how wordpress removes index.php. I hope you will get something after reading this article. Let's discuss it together.

Wordpress remove index.php method: first log in to the wordpress background; then select "set-fixed link" and set the link; then set wordpress rewriting rules; finally, create a new htaccess file under the wordpress website directory.

Wordpress's method of getting rid of index.php

There are two main steps:

1-1) wordpress settings permalink

Log in to the wordpress backend

Select 'Settings / fixed links' in turn

On the page that appears

Select Custom structure

And then, according to your situation,

Set up the link.

1-2) set wordpress rewriting rules

This needs to be decided according to your web server

1-2-1) wordpress apache static link rewriting rules

If you are apache

Under the wordpress website directory

Create a new .htaccess file

And write the following code

RewriteEngine OnRewriteBase / wordpress/RewriteRule ^ index\ .php $- [L] RewriteCond% {REQUEST_FILENAME}!-fRewriteCond% {REQUEST_FILENAME}!-dRewriteRule. / wordpress/index.php [L]

1-2-2) wordpress nginx static link rewriting rules

If your web server is nginx

Edit nginx's configuration file nginx.cnf

In the server {} configuration content

Write the following code

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

Then restart nginx

This removes the index.php from the wordpress link.

After reading this article, I believe you have some understanding of "how to remove index.php from wordpress". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Tags: Links rules files selections code background methods servers directories articles websites static faceted services login configuration two content finished situation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Technology macOS OPPO Reno vpn