135-1821-9792

wordpress斜杠 word 斜杠

wordpress文章链接.html怎么自动加了斜杠

果然给我在codex上找到了解决方案,就是简单地加一行斜杠重定向而已,方法综述如下:

创新互联公司专注于成都网站设计、网站建设、网页设计、网站制作、网站开发。公司秉持“客户至上,用心服务”的宗旨,从客户的利益和观点出发,让客户在网络营销中找到自己的驻足之地。尊重和关怀每一位客户,用严谨的态度对待客户,用专业的服务创造价值,成为客户值得信赖的朋友,为客户解除后顾之忧。

1、登录shell,vim编辑Nginx配置目录(一般是在/usr/local/nginx/conf/)下的"wordpress.conf",当然如果你像我一样用的是自己写的conf文件,那就改对应的那个重定向配置文件就好。

?

1

vim /usr/local/nginx/conf/wordpress.conf

2、把官方给的那一行加到文件最后面就行了

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

location /blog/ {

if ($host != '' ) {

rewrite ^/(.*)$ // permanent;

}

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 (.*) /blog/index.php;

}

}

rewrite /wp-admin$ $scheme://$host$uri/ permanent;

3、:wq保存重启nginx即可

其实你要是懒的话,直接用 "echo " 追加就行了= =

PS:据说 nginx不会自动在请求的最后加上一个斜线,不会自动判断请求的是一个文件还是一个目录。网上搜索 nginx 斜线,都会提到需要在请求的最后加上这个斜杠。

网上大部资料是这样写的 :

在nginx\conf\vhost.conf中的 location / {}的index index.html后面加上

?

1

2

3

if (-d $request_filename) {

rewrite ^/(.*)([^/])$ permanent;

}

但如果你的网址后面带了端口的话,那么转向时还是会出现403错误。

即 $host 变量把端口弄没了,改成 $http_host 变量即可

改成如下写法即解决了所有问题

?

1

2

3

if (-d $request_filename) {

rewrite ^/(.*)([^/])$ permanent;

}

wordpress安装首页后面为什么会有两个斜杠

这个你可以调置一下后台就可以解决

操作方法:

后台——设置——常规

在常规页面,有“站点标题”和“副标题”

你的这个wordpress可能就在副标题那,

删除它就可以了。

还有一种方法,

就是修改你的主题的header.php文件中的title与/title之间的代码也可以实现。

希望帮到你。

如何实现WordPress分类目录和页面链接地址以斜杠/结尾

面介绍3 给niwordpress增加.html缀:

1简单修改固定链接

wordpress自带固定链接改变链接式格式没写能给ni页面访问带困难链接特殊符号 空格包含文固定链接格式:/%postname%.html 文行wo格式/archives/%post_id%.html

2插件实现

单独页面添加.html缀

安装:.html on PAGES 插件实现启用插件需任何设置

类及页面同添加.html缀

安装:.html in category and page url 插件启用插件需要插件设置页面保存设置

需要注意启用插件需要台固定链接设置重新保存设置否则跳404页面功先删除空间根目录.htaccess文件保存自新

另外安装插件能造志页翻页错误…..

3.既插件代码

面代码添加主题functions.php即

// 页面链接添加html缀

add_action('init', 'html_page_permalink', -1);

function html_page_permalink() {

global $wp_rewrite;

if ( !strpos($wp_rewrite-get_page_permastruct(), '.html')){

$wp_rewrite-page_structure = $wp_rewrite-page_structure . '.html';

}

}

添加需要固定链接设置页面重新保存固定链接设置否则效

述代码适合伪静态固定链接形式使用比:

/%postname%.html

/%post_id%.html

另外同使用给WordPress类目录页面添加斜杠文代码需要该文代码修改:

// 添加斜杠

function nice_trailingslashit($string, $type_of_url) {

if ( $type_of_url != 'single' $type_of_url != 'page' )

$string = trailingslashit($string);

return $string;

}

add_filter('user_trailingslashit', 'nice_trailingslashit', 10, 2);

排除页面文件否则页面链接.html面自加斜杠

wordpress文章链接.html/怎么自动加了斜杠

下面介绍3中方法 给你的wordpress增加.html后缀:

1,最简单的方法修改固定链接

wordpress的自带的固定链接可以改变链接样式,但是如果格式没写好,可能给你的页面访问带来困难,链接中特殊符号 空格,还是包含中文。固定链接格式:/%postname%.html 这个样就为中文,但是也是可行的。我个人的格式是/archives/%post_id%.html。

2,插件也可以实现

单独为页面添加.html后缀

安装:.html on PAGES 插件实现,启用插件后无需任何设置。

分类及页面同时添加.html后缀

安装:.html in category and page url 插件,启用插件后需要到插件设置页面保存一下设置。

需要注意的是,启用插件后还需要到后台固定链接设置中,重新保存一下设置,否则会跳到404页面,如果不成功可以先删除空间根目录的.htaccess文件,之后保存会自动生成新的。

另外,安装插件后可能会造成日志分页翻页错误…..

3.既然可以插件当然代码可以

将下面代码添加主题functions.php中即可

// 页面链接添加html后缀

add_action('init', 'html_page_permalink', -1);

function html_page_permalink() {

global $wp_rewrite;

if ( !strpos($wp_rewrite-get_page_permastruct(), '.html')){

$wp_rewrite-page_structure = $wp_rewrite-page_structure . '.html';

}

}

添加后,需要到固定链接设置页面,重新保存一下固定链接设置,否则不会生效。

上述代码适合伪静态的固定链接形式使用,比如:

/%postname%.html

/%post_id%.html

另外,如果同时使用了“给WordPress分类目录和页面添加斜杠”一文中的代码,还需要将该文中的代码修改为:

// 添加斜杠

function nice_trailingslashit($string, $type_of_url) {

if ( $type_of_url != 'single' $type_of_url != 'page' )

$string = trailingslashit($string);

return $string;

}

add_filter('user_trailingslashit', 'nice_trailingslashit', 10, 2);

排除页面文件,否则页面链接.html后面也会自动加上斜杠。


新闻名称:wordpress斜杠 word 斜杠
URL标题:http://kswsj.com/article/doijgog.html

其他资讯



Copyright © 2009-2022 www.kswsj.com 成都快上网科技有限公司 版权所有 蜀ICP备19037934号