wordpress教程

WordPress伪静态规则设置方法

我的站长站 2021-03-09 人阅读

根据服务器主机空间环境,只需加入下列伪静态规则即可。

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]


相关推荐
  • 伪静态规则
  • RewriteRule-htaccess伪静态规则写法和常用规则

    伪静态匹配规则.换行符以外的所有字符\w 匹配字母或数字或下划线或汉字\s 匹配任意的空白符\d 匹配数字\b 匹配单词的开始或结束^ 匹配字符串的开始$ 匹配字符串的结束* 重复零次或更多次+ 重复一次或更多次? 重复零次或一次{n} 重复n次{n,}重复...

    经验分享 42 1年前
  • 帝国cms7.2默认伪静态规则

    暂时只有APACHE IIS6 IIS7的规则,其他规则自行对照修改即可。不是很严谨,自己可以往严谨中修改:仅供参考!apache下的.htaccess:RewriteEngine OnErrorDocument 404 /404.htmlRewritebase /#信息列表RewriteCond %{QUERY_STRING} ^(.*)$RewriteRule ^l...

    帝国cms教程 686 8年前
  • 帝国TAGS标签伪静态调用+伪静态规则教程

    帝国CMS灵动标签SQL调用TAGS标签代码<?php$tsql=$empire->query("select * from {$dbtbpre}enewstags order by num desc");while($tr=$empire->fetch($tsql)){?><a href="/tag/<?=$tr[&#39;path&#39;]?>.html" target="_blank&qu...

    帝国cms教程 339 6年前
最新更新