免费空间不支持伪静态这很头疼~
今天小的来给大家分享一下wordpress利用404来伪静态!
首先去后台设置为指定的文件为404页面
标准互联的位置在-
[进入高级控制面版]-然后点击404错误提示!
名字任意我这里写的host.php 写什么都可以。
设置好之后,复制下面代码
<?php
// This is the default file for the site. Usually index.php
$default = 'index.php';
// The name of this file.
// Set this value for the URL in Custom Error Properties of your website in IIS.
// Goto: IIS Manager > Websites > [Site Name] > Properties > Custom Errors >
// 404 & 404;2 & 404;3 > URL (Requires a '/' prefix in IIS).
$thisfile = '404.php'; //404.php
$_SERVER['ORIG_PATH_TRANSLATED'] = str_replace($thisfile, $default, $_SERVER['ORIG_PATH_TRANSLATED']);
$_SERVER['SCRIPT_FILENAME'] = str_replace($thisfile, $default, $_SERVER['SCRIPT_FILENAME']);
$_SERVER['ORIG_PATH_INFO'] = str_replace($thisfile, $default, $_SERVER['ORIG_PATH_INFO']);
$_SERVER['SCRIPT_NAME'] = str_replace($thisfile, $default, $_SERVER['SCRIPT_NAME']);
$_SERVER['PHP_SELF'] = str_replace($thisfile, $default, $_SERVER['PHP_SELF']);
$_SERVER['PATH_INFO'] = false;
$qs =& $_SERVER['QUERY_STRING'];
$ru =& $_SERVER['REQUEST_URI'];
$pos = strrpos($qs, '://');
$pos = strpos($qs, '/', $pos + 4);
$_SERVER['URL'] = $ru = substr($qs, $pos);
$qs = trim(stristr($ru, '?'), '?');
// Required for WordPress 2.8+
$_SERVER['HTTP_X_ORIGINAL_URL'] = $ru;
// Fix GET vars
foreach ( $_GET as $var => $val ) {
if ( substr($var, 0, 3) == '404') {
if ( strstr($var, '?') ) {
$newvar = substr($var, strpos($var, '?') + 1);
$_GET[$newvar] = $val;
}
unset($_GET[$var]);
}
break;
}
include($default);
?>
复制代码
然后上传到ftp同网站的根目录即可!ok现在可以去wordpress后台设置你想要的固定链接了!
不过这样设置wordpress后文章伪静态可以正常浏览,可是标签还是会出现404。
下面我们需要下载一个插件来解决wordpress伪静态后标签出现404的问题!
下载Auto Tag Slug
在wordpress后台搜索Auto Tag Slug即可!
这样就可以完美的解决wordpress在win主机下不支持伪静态了。
上一篇:新站如何选择好域名
下一篇:为何申请的空间还没有开通就消失了?会员也无法登录了?
本文地址:https://www.128sj.com/jiaocheng/20160415312.html,转载请注明出处