解决windows主机下wordpress伪静态的方法

2010年1月2日14:07:02网站建设2539

第一步、新建一个记事本,在里面写入下面代码保存为txt格式,重新命名为404.php,上传到网站根目录文章源自堕落的鱼-https://www.duoluodeyu.com/64.html

代码:文章源自堕落的鱼-https://www.duoluodeyu.com/64.html

<?php
$qs = $_SERVER['QUERY_STRING'];
$_SERVER['REQUEST_URI'] = substr($qs, strpos($qs, ':80')+3);
$_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI'];
include('index.php');
?>
第二步、到你的虚拟主机控制面板,设置404自定义错误指向404.php

第三步、进入WordPress管理后台,点击设置(Options),点击固定链接(Permalinks)文章源自堕落的鱼-https://www.duoluodeyu.com/64.html

以上的修改只能实现网址中只含有英文字符的伪静态,如果你要同时实现网址中包含中文字符的伪静态,请将上面的代码换成如下的代码:文章源自堕落的鱼-https://www.duoluodeyu.com/64.html

<?php
$qs = $_SERVER['QUERY_STRING'];
$_SERVER['REQUEST_URI'] = substr($qs, strpos($qs, ':80')+3);
$_SERVER['PATH_INFO'] = iconv("GBK//IGNORE", "UTF-8//IGNORE", $_SERVER['REQUEST_URI']);
include('index.php');
?>

附录:设置静态链接常用参数文章源自堕落的鱼-https://www.duoluodeyu.com/64.html

%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
文章源自堕落的鱼-https://www.duoluodeyu.com/64.html
WebP图像文件格式简介 网站建设

WebP图像文件格式简介

WebP是一种图像文件格式,由Google开发,旨在提供更高的图像压缩效率和更好的图像质量。它采用了基于无损和有损压缩的算法,可以显著减小图像文件的大小,同时保持较高的视觉质量。 相比于传统的JPEG...
常用正则表达式汇总 网站建设

常用正则表达式汇总

很多不太懂正则的朋友,在遇到需要用正则校验数据时,往往是在网上去找很久,结果找来的还是不很符合要求。所以我最近把开发中常用的一些正则表达式整理了一下,在这里分享一下。给自己留个底,也给朋友们做个参考。...
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定

评论:2   其中:访客  1   博主  0   引用   1
    • 陌凡
      陌凡 0

      陌凡,不错学习

    • 来自外部的引用: 1