您好,游客注册登录繁體
seo网络营销大神学习: 618234418
首页 >> 江西SEO >> wordpress如何路径伪静态处理

wordpress如何路径伪静态处理

江西SEO 2016-10-08 10
浏览次数6187

一直以来很多同学学了路径优化,总是纠结网站如何做伪静态处理,今天我来分享wordpress如何路径伪静态处理;(本地网站为例)

没处理之前 基本路径像这种:http://www.yefanseo.com/?p=905

或者这种:http://127.0.0.1/wordpress/?p=4

wordpress如何路径伪静态处理

 

处理方法:

第一种:设置-固定链接-自定义结构(后面加上:/%post_id%.html)

网站伪静态处理

保存之后,我们再来看下:

wordpress如何路径伪静态处理

 

这样就成功了  是不是很简单呢!

 

注意:当然,每种空间环境不一样,那么不一定100%解决,所以需要配备环境规则,其他的类似;

下面是支持wordpress的伪静态规则

 

IIS伪静态规则

IIS 环境是 Windows 主机常用的服务器环境,新建一个 txt 文件,将下面的代码添加到文件中:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[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]

保存,删除记事本的名字,包括后缀名.txt一起删掉,修改为(.htaccess)上传根目录就可以了。

Apache伪静态规则

Apache是 Linux 主机下常见的环境,现在一般的 Linux 虚拟主机都采用这种环境。新建一个 htaccess.txt 文件,添加下面的代码:

1
2
3
4
5
6
7
8
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

然后上传到 WordPress 站点的根目录,重命名为 .htaccess 即可

Nginx伪静态规则

Nginx环境一般是Linux 主机 VPS或服务器用户用的比较多,这些用户一般都会自己配置Nginx,或者有专门的人帮你配置,打开 nginx.conf 或者某个站点的配置环境,比如 wpdaxue.com.conf(不同人配置的不一样),在  server   { } 大括号里面添加下面的代码:

1
2
3
4
5
6
7
8
9
10
11
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;
        }
}

保存,重启 Nginx 即可。

全部评论:10
1#
卢松松博客2016年12月13日下午6:56 回复

猛然发现,博主没做伪静态

    2#
    江西SEO2016年12月18日下午7:43 回复

    哈哈,特意没做

3#
Ienpai2017年1月18日上午11:36 回复

子目录伪静态,访问404错误。

4#
武汉SEO2018年3月8日下午2:47 回复

居然把昵称主页名链接加nofno了,想加个友链只能手动打了,老师博客真好,学员来蹭外链啦…………
武汉SEO http://www.mochenseo.com/

5#
SEO12018年6月30日下午2:33 回复

确实未作伪静态

6#
JY2018年8月25日下午5:04 回复

老师现在还在教课吗?

7#
文娱帝国2019年3月30日下午8:46 回复

写的很好,很喜欢

8#
iMJMJ2022年1月11日上午5:10 回复

学习学习,必须的!谢谢!

9#
iMJMJ2022年1月11日上午5:10 回复

评论内容…

10#
顶点软件2023年5月9日下午2:23 回复

你写得非常清晰明了,让我很容易理解你的观点。