wordpress 用 nginx做服务器时,mode_rewrite(固定连接)的配置

本文分享了在使用Nginx作为Web服务器时如何解决WordPress固定链接问题的经验,包括了解Nginx与Apache的不同之处,如Nginx不支持mod_rewrite模块但可以通过正则表达式路由来实现类似功能。

http://www.gongzi.org/nginxstartwp-super-cache-mod_rewrite.html 原文地址

这个问题纠结了一个下午,终于搞定。
但是也不白纠结,复习了Linux的命令。
刚开始本打算用wordpress插件的方式解决,但是后来试了半天 WP Super Cache(不知道什么情况) 还是不行。
最后无奈之际看一个比较容易的方法(心开始不信它行的),靠~ 居然解决了~~
最后弄清楚了两个问题
1. 只有apache才有 mode_rewrite 模块,nginx 没有这样的模块。
2. nginx 可以正则表达式路由,从而解决wordpress 固定连接的问题。

tips: 查看正在运行的进程查看进程所在绝对路径
nginx -s reload(nginx 重启命令)还有nginx居然是俄罗斯人搞的~

LNMP是一个基于CentOS/Debian编写的Nginx、PHP、MySQL、phpMyAdmin、eAccelerator一键安装包。可以在VPS、独立主机上轻松的安装LNMP生产环境。

<?php /** * The base configuration for WordPress * * The wp-config.php creation script uses this file during the installation. * You don't have to use the website, you can copy this file to "wp-config.php" * and fill in the values. * * This file contains the following configurations: * * * Database settings * * Secret keys * * Database table prefix * * ABSPATH * * @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/ * * @package WordPress */ // ** Database settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define( 'DB_NAME', 'HeroicNews' ); /** Database username */ define( 'DB_USER', 'HeroicNews' ); /** Database password */ define( 'DB_PASSWORD', '@Duyj0416' ); /** Database hostname */ define( 'DB_HOST', 'localhost' ); /** Database charset to use in creating database tables. */ define( 'DB_CHARSET', 'utf8mb4' ); /** The database collate type. Don't change this if in doubt. */ define( 'DB_COLLATE', '' ); /**#@+ * Authentication unique keys and salts. * * Change these to different unique phrases! You can generate these using * the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}. * * You can change these at any point in time to invalidate all existing cookies. * This will force all users to have to log in again. * * @since 2.6.0 */ define( 'AUTH_KEY', '~6/4W1tT5l,${b8pfD@7@2LUbpVq=_OR%LU:USE2p_!;yM6^.1?$T/.OvV3oI7bb' ); define( 'SECURE_AUTH_KEY', '.*!?.,{~WbbCbtK4,j z2gE12atkQXgI08C5$%~o$AQ[ &j5fz&.xc+-nnu_&f`.' ); define( 'LOGGED_IN_KEY', '!Ib` GW^yvGWb <kTg$!MrLe&r+p]m1wwG<(tk9hNI3$e@>P^3VVU_S$F]:Jv!p]' ); define( 'NONCE_KEY', ']%[J7`Z2hr<+Yzijh8rnP=aBQZx]kHfvfJE+oWLI1N>1x;hiwyc*>s!SMoYgDwyA' ); define( 'AUTH_SALT', 'yL=?bov2[:,(|`!2zF,s(d^L$h|sm9{Q<PC.{W6hlX%NIjyK0P?:zMdM/TmU<:Jx' ); define( 'SECURE_AUTH_SALT', 'N(aiZ`$dp?2=3X }${GoCbw{GN)6hoApqo@EVVa>>CWOVmE{tWa~e+=56mNGl@ju' ); define( 'LOGGED_IN_SALT', 'Q@]no)0oU/K71{U,%eWatd}OIDCb5+$kje?)u&Q?_E=^=z`Q$T[{[RZ7nr/b hS?' ); define( 'NONCE_SALT', 'a7[N_!;,}BIX!8PrL<RKF]zCjWIv0ZMwe;dWh>@q2;MM_}ja?]-.,m!!0)d9o5m3' ); /**#@-*/ /** * WordPress database table prefix. * * You can have multiple installations in one database if you give each * a unique prefix. Only numbers, letters, and underscores please! * * At the installation time, database tables are created with the specified prefix. * Changing this value after WordPress is installed will make your site think * it has not been installed. * * @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/#table-prefix */ $table_prefix = 'wp_'; /** * For developers: WordPress debugging mode. * * Change this to true to enable the display of notices during development. * It is strongly recommended that plugin and theme developers use WP_DEBUG * in their development environments. * * For information on other constants that can be used for debugging, * visit the documentation. * * @link https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/ */ define( 'WP_DEBUG', false ); /* Add any custom values between this line and the "stop editing" line. */ /* That's all, stop editing! Happy publishing. */ /** Absolute path to the WordPress directory. */ if ( ! defined( 'ABSPATH' ) ) { define( 'ABSPATH', __DIR__ . '/' ); } /** Sets up WordPress vars and included files. */ require_once ABSPATH . 'wp-settings.php';
最新发布
08-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值