常用的参数有
很多站长在玩 WordPress 的时候,可能会碰到一个问题,就是想把 WordPress 伪静态,在后台设置好固定链接之后,就会出现文章页面或者所有的页面都出现 404 错误。下面就提供各种 web 环境下的 WordPress 伪静态规则设置教程。
Apache 伪静态规则
Apache 是 Linux 主机下常见的环境,现在一般的 Linux 虚拟主机都采用这种环境。新建一个 htaccess.txt 文件,添加下面的代码:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
然后上传到 WordPress 站点的根目录,重命名为 .htaccess ,修改完成后,要重启 Apache 才能生效。
Nginx伪静态规则
打开nginx.conf
或者某个站点的配置环境,比如 qq52o.me.conf
(不同的网站配置不一样),在server {}
大括号里面添加下面的代码:
location / { index index.html index.php; 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; } } rewrite /wp-admin$ $scheme://$host$uri/ permanent;
保存以后,重启 Nginx 即可。
IIS 伪静态
强烈不推荐在 windows 的 IIS 服务器下安装 WordPress,因为 IIS 环境运行 PHP 程序的效率,相对同等配置下 Linux 的 Apache 和 Nginx 环境,要低的多,更甚至于坑太多!
[ISAPI_Rewrite] # Defend your computer from some worm attacks #RewriteRule .*(?:global.asa|default\.ida|root\.exe|\.\.).* . [F,I,O] # 3600 = 1 hour CacheClockRate 3600 RepeatLimit 32 # Protect httpd.ini and httpd.parse.errors files # from accessing through HTTP # Rules to ensure that normal content gets through RewriteRule /tag/(.*) /index\.php\?tag=$1 RewriteRule /software-files/(.*) /software-files/$1 [L] RewriteRule /images/(.*) /images/$1 [L] RewriteRule /sitemap.xml /sitemap.xml [L] RewriteRule /favicon.ico /favicon.ico [L] # For file-based wordpress content (i.e. theme), admin, etc. RewriteRule /wp-(.*) /wp-$1 [L] # For normal wordpress content, via index.php RewriteRule ^/$ /index.php [L] RewriteRule /(.*) /index.php/$1 [L]
另存为 httpd.ini 文件,上传到 WordPress 站点的根目录即可。
宝塔面板设置伪静态
如果你的服务器上安装了宝塔面板,就方便多了
在 宝塔面板>网站>设置>伪静态 里选择对应的伪静态规则(WordPress)并保存即可。
后记
如果你按照上述方法设置了还是不起作用,那么有可能是你的服务器没有安装伪静态模块!Apache 服务器的话,就是 rewrite 模块没有开启,去除这一行前面的#号就可以了
LoadModule rewrite_module modules/mod_rewrite.so]]>
<script type="text/javascript">
/*富强民主文明和谐*/
var a_idx = 0;
jQuery(document).ready(function($) {
$("body").click(function(e) {
var a = new Array("富强", "民主", "文明", "和谐", "自由", "平等", "公正" ,"法治", "爱国", "敬业", "诚信", "友善", "手麻了", "歇会儿");
var $i = $("<span/>").text(a[a_idx]);
a_idx = (a_idx + 1) % a.length;
var x = e.pageX,
y = e.pageY;
$i.css({
"z-index": 9999,
"top": y - 20,
"left": x,
"position": "absolute",
"font-weight": "bold",
"color": "#ff6651"
});
$("body").append($i);
$i.animate({
"top": y - 180,
"opacity": 0
},
1500,
function() {
$i.remove();
});
});
});
</script>
]]>2、WP Fastest Cache 压缩文件,添加缓存设置,加快网站加载速度
3、Smush Image Compression and Optimization 网站图片压缩,减小图片大小
4、Google XML Sitemaps 网站地图
5、Clicky for WordPress 网站数据分析(试用一段时间后需付费)
6、Shortcodes Ultimate 多种文本编辑样式简码
7、Genesis Simple Edits和Genesis Super Customizer Genesis主题必备插件
8、Really Simple SSL 用于HTTPS设置
9、WP Mail SMTP和WPForms Lite 网站邮件设置
10、Akismet 反病毒,反垃圾评论
11、TinyMCE Advanced 必备编辑器插件,增加编辑器设置项
12、Rel Nofollow Checkbox 设置链接nofollow属性
13、Google Analytics for WordPress by MonsterInsights 集成Google Analytics到WordPress面板中
14、WP Statistics 详细的访问日志统计插件,会产生大量数据库日志,拖慢网站加载速度,不建议使用
]]>