1、第一步操做php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>正则表达式
# END WordPressapache
这是咱们开启了固定连接功能以后,wordpress给咱们加上的htaccess文件服务器
冷博客来解释一下各行含义wordpress
2、第二步注意ui
<IfModule mod_rewrite.c>博客
#若是mode_rewrite.c模块存在 则执行如下指令it
RewriteEngine Onio
#开启rewriteEngineast
RewriteBase /
#重写范围,这里/为本地顶级目录
RewriteRule ^index\.php$ – [L]
#重写规则
^index\.php$是匹配正则表达式,只匹配了index.php
后面的短线 若是我没记错的话 就是指null
后面的L是结束符号,同等级的还有
[L](last):终止一系列的RewriteCond和RewriteRule
[R](redirect):触发一个显示的跳转,也能够指定跳转类型,如[R=301]
[F](forbidden):禁止查看特定文件,apache会触发403错误
[NC](no case):表示忽略大小写
3、详见文章末尾才出处
其中返回值301也会有其余类型,好比
经常使用的客户端请求错误返回代码:
401 Authorization Required
403 Forbidden
404 Not Found
405 Method Not Allowed
408 Request Timed Out
411 Content Length Required
412 Precondition Failed
413 Request Entity Too Long
414 Request URI Too Long
415 Unsupported Media Type
常见的服务器错误返回代码:
500 Internal Server Error
RewriteRule . /index.php [L]
#一样是重写规则
最后,详见文章末尾才出处
表明任意字符,替代为/index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#上面两个均为重写条件,%{}中内容为apache定义的一系列返回参数
//我的理解:
f:file文件
d:directory 目录(文件夹)