时间:2021-05-25
伪静态:即网站本身是动态网页如.php、.asp、.aspx等格式,而这类网页还带“?”加参数来读取数据库。开启伪静态后,动态网页即被转换重写成静态网页类型页面。
WordPress和其它网站系统不一样,其它网站系统基本都带有生成静态页面功能。但Wp只能使用伪静态。
现在的主机基本都会支持伪静态功能,只需在空间后台伪静态功能,选择网站系统,空间就会支持该系统的伪静态。
如何判读空间是否支持伪静态。在网站后台:设置-固定链接,选择第一个除外,看网站其它页面是否出现404,如果是,则空间不支持伪静态。
只要空间支持伪静态重写URL Rewrite功能,根据服务器主机空间环境,只需加入下列伪静态规则即可。
Apache伪静态规则
新建一个 txt 文件,将下面的代码添加到文件中,然后另存为.htaccess文件,上传到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>
Nginx规则
在Nginx中的server模块配置如下内容,打开 nginx.conf 或者某个站点的配置环境,例如 /usr/local/nginx/conf/yzipi.conf,在server{ } 大括号里面添加下面的代码。
location / {
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){
IIS伪静态规则rewrite (.*) /index.php;
}
}
IIS伪静态规则
新建一个 txt 文件,将下面的代码添加到文件中,然后另存为 httpd.ini 文件,上传到WordPress站点的根目录即可。
[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]
参考链接Apache Module mod_rewrite
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
Nginx下让WordPress支持固定链接的伪静态规则要让nginx支持wordpress固定链接非常简单,需要自己进行添加点配置代码:复制代码代码如下:lo
第一种:win系统下的wordpress程序伪静态。wordpress在win系统下的伪静态前提是必须空间系统支持伪静态设置,而我们也知道一般win系统支持的伪
LinuxXAMPP下启用WordPress的自定义文件名(伪静态)功能在安装好WORDPRESS后,想启用伪静态的功能,一个是为了好看,另外也是为了更好的SE
伪静态方法一:复制代码代码如下:复制代码代码如下:伪静态方法二:伪静态方法三:复制代码代码如下:伪静态方法四:复制代码代码如下:
帝国CMS7.0提供了伪静态的设置,本文就帝国7.0下伪静态Apache的Rewrite设置方法简述如下:复制代码代码如下:#将RewriteEngine模式打