一、帝国CMS伪静态设置技巧
帝国CMS建议直接生成静态页,但有时候也确实希望伪静态,这里以 帝国CMS7.0为例。
1、确认空间支持伪静态,有些空间商的空间是需要手动开启伪静态功能的。
2、后台–系统–系统设置–伪静态参数设置,设置好伪静态规则。
3、新建 .htaccess 文件,放在网站根目录下。
.htaccess文件中写入如下规则:(注意规则文件中的规则要与后台设置的一致)
# 将 RewriteEngine 模式打开
RewriteEngine On
#信息内容页:showinfo-[!--classid--]-[!--id--]-[!--page--].html
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^showinfo-(.+?)-(.+?)-(.+?)/.html$ /e/action/ShowInfo.php?classid=$1&id=$2&page=$3
#信息列表:listinfo-[!--classid--]-[!--page--].html
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^listinfo-(.+?)-(.+?)/.html$ /e/action/ListInfo/index.php?classid=$1&page=$2
#标题分类列表页:infotype-[!--ttid--]-[!--page--].html
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^infotype-(.+?)-(.+?)/.html$ /e/action/InfoType/index.php?ttid=$1&page=$2
#TAGS信息列表页:tags-[!--tagname--]-[!--page--].html
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^tags-(.+?)-(.+?)/.html$ /e/tags/index.php?tagname=$1&page=$2
二、WordPress伪静态设置规则
修改WordPress固定链接伪静态化后,网页却打不开,出现这种情况这是因为缺少伪静态规则。
WordPress固定链接伪静态化设置规则,是根据你主机环境来决定的,不需要插件,网上运行的wordpress无非IIS/Apache/Nginx这三种环境。
WordPress固定链接伪静态化设置技巧多种多样,需要对号入座。如果使用的是虚拟主机,大多数的IDC服务商,都支持wordpress伪静态,直接在后台修改固定链接设置即可。
1、Linux
请确保你的根目录开启了777权限,已开启的话,在修改自定义固定链接后的瞬间,会在主机根目录自动生成一个.htaccess的文件,打开查看是否已生成规则,生成的话,就OK了,就不需要往下看了。
如果没有生成.htaccess,或者.htaccess里没有内容,那就需要手动创建一个txt文件,使用上传软件修改名为 .htaccess,粘贴Apache或Nginx规则代码,保存并上传到网站根目录就行了。
Apache规则
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Nginx规则
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){
rewrite (.*) /index.php;
}
}
2、Windows主机IIS环境下伪静态规则
你使用的windows主机必须安装了装Rewrite 组件才能支持伪静态,咨询下你的
如果主机支持伪静态,在修改wordpress固定链接后无法伪静态,在根目录自动生成一个httpd.ini,没有生成的话,就创建一个txt文本,修改名字为httpd.ini,复制粘贴下边代码,保存上传到根目录。
[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]
PS:
如果你不知道所使用的主机是什么系统,或使用的Linux或Windows系统的
以上是虚拟主机伪静态怎么设置的详细说明,如果还有疑问,可以到