第一步、新建一个记事本,在里面写入下面代码保存为txt格式,重新命名为404.php,上传到网站根目录
代码:
<?php
$qs = $\_SERVER['QUERY\_STRING'];
$\_SERVER['REQUEST\_URI'] = substr($qs, strpos($qs, ':80')+3);
$\_SERVER['PATH\_INFO'] = $\_SERVER['REQUEST\_URI'];
[include](http://www.duoluodeyu.com)('index.php');
?>
**第二步、**到你的虚拟主机控制面板,设置404自定义错误指向404.php
第三步、进入WordPress管理后台,点击设置(Options),点击固定链接(Permalinks)
以上的修改只能实现网址中只含有英文字符的伪静态,如果你要同时实现网址中包含中文字符的伪静态,请将上面的代码换成如下的代码:
<?php
$qs = $\_SERVER['QUERY\_STRING'];
$\_SERVER['REQUEST\_URI'] = [substr](http://www.duoluodeyu.com)($qs, [strpos](http://www.duoluodeyu.com)($qs, ':80')+3);
$\_SERVER['PATH\_INFO'] = iconv("GBK//IGNORE", "UTF-8//IGNORE", $\_SERVER['REQUEST\_URI']);
[include](http://www.duoluodeyu.com)('index.php');
?>
附录:设置静态链接常用参数
%year% The year of the post, four digits, for example 2004 %monthnum% Month of the year, for example 05 %day% Day of the month, for example 28 %hour% Hour of the day, for example 15 %minute% Minute of the hour, for example 43 %second% Second of the minute, for example 33 %postname% A sanitized version of the title of the post (post slug field on Edit Post/Page panel). So “This Is A Great Post!” becomes this-is-a-great-post in the URI (see Using only %postname%). Starting Permalinks with %postname% is strongly not recommended for performance reasons.. *** Note - this has been changed and is ok to do since ver. 2.0 %post_id% The unique ID # of the post, for example 423 %category% A sanitized version of the category name (category slug field on New/Edit Category panel). Nested sub-categories appear as nested directories in the URI. Starting Permalinks with %category% is strongly not recommended for performance reasons. %tag% A sanitized version of the tag name (tag slug field on New/Edit Tag panel).Starting Permalinks with %tag% is strongly not recommended for performance reasons. %author% A sanitized version of the author name