- 固定链接格式为:/html/%post_id%.html
- // 添加分页处理规则
- function add_custom_post_rewrite_rules($rules) {
- $custom_rules = array(
- 'html/([0-9]+)-([0-9]+)\.html$' => 'index.php?p=$matches[1]&page=$matches[2]',
- );
- $rules = array_merge($custom_rules, $rules);
- return $rules;
- }
- add_filter('post_rewrite_rules', 'add_custom_post_rewrite_rules');
- // 修改分页链接
- function my_wp_link_pages($args = '') {
- $args .= ($args ? '&' : '') . 'echo=0';
- $links = wp_link_pages($args);
- $links = preg_replace_callback('|(html/)([0-9]+)(\.html)(/)([0-9]+)|', 'custom_page_link', $links);
- echo $links;
- }
- function custom_page_link($matches) {
- return $matches[1].$matches[2].'-'.$matches[5].$matches[3];
- }
相关Apache下的RewriteRule
- <IfModule mod_rewrite.c>
- RewriteEngine On
- RewriteBase /
- RewriteRule ^html/([0-9]+)\.html/trackback/?$ index.php?p=$1&tb=1 [L]
- RewriteRule ^html/([0-9]+)\.html/feed/(feed|rdf|rss|rss2|atom)/?$ index.php?p=$1&feed=$2 [L]
- RewriteRule ^html/([0-9]+)\.html/(feed|rdf|rss|rss2|atom)/?$ index.php?p=$1&feed=$2 [L]
- RewriteRule ^html/([0-9]+)\.html/page/?([0-9]{1,})/?$ index.php?p=$1&paged=$2
- RewriteRule ^html/([0-9]+)\.html/([0-9]+)/?$ index.php?p=$1&page=$2
- </IfModule>
- 固定链接格式为:/html/%postname%.html
- // 添加分页处理规则
- function add_custom_post_rewrite_rules($rules) {
- $custom_rules = array(
- 'html/([^/]+)-([0-9]+)\.html$' => 'index.php?name=$matches[1]&page=$matches[2]',
- );
- $rules = array_merge($custom_rules, $rules);
- return $rules;
- }
- add_filter('post_rewrite_rules', 'add_custom_post_rewrite_rules');
- // 修改分页链接
- function my_wp_link_pages($args = '') {
- $args .= ($args ? '&' : '') . 'echo=0';
- $links = wp_link_pages($args);
- $links = preg_replace_callback('|(html/)([^/]+)(\.html)(/)([0-9]+)|', 'custom_page_link', $links);
- echo $links;
- }
- function custom_page_link($matches) {
- return $matches[1].$matches[2].'-'.$matches[5].$matches[3];
- }
相关Apache下的RewriteRule
- <IfModule mod_rewrite.c>
- RewriteEngine On
- RewriteBase /
- RewriteRule ^html/([^/]+)\.html/trackback/?$ index.php?name=$1&tb=1 [L]
- RewriteRule ^html/([^/]+)\.html/feed/(feed|rdf|rss|rss2|atom)/?$ index.php?name=$1&feed=$2 [L]
- RewriteRule ^html/([^/]+)\.html/(feed|rdf|rss|rss2|atom)/?$ index.php?name=$1&feed=$2 [L]
- RewriteRule ^html/([^/]+)\.html/page/?([0-9]{1,})/?$ index.php?name=$1&paged=$2 [L]
- RewriteRule ^html/([^/]+)\.html/([0-9]+)/?$ index.php?name=$1&page=$2 [L]
- </IfModule>
- 固定链接格式为:/post/%postname%.html
- // 添加分页处理规则
- function add_custom_post_rewrite_rules($rules) {
- $custom_rules = array(
- 'post/([^/]+)-([0-9]+)\.html$' => 'index.php?name=$matches[1]&page=$matches[2]',
- );
- $rules = array_merge($custom_rules, $rules);
- return $rules;
- }
- add_filter('post_rewrite_rules', 'add_custom_post_rewrite_rules');
- // 修改分页链接
- function my_wp_link_pages($args = '') {
- $args .= ($args ? '&' : '') . 'echo=0';
- $links = wp_link_pages($args);
- $links = preg_replace_callback('|(post/)([^/]+)(\.html)(/)([0-9]+)|', 'custom_page_link', $links);
- echo $links;
- }
- function custom_page_link($matches) {
- return $matches[1].$matches[2].'-'.$matches[5].$matches[3];
- }
相关Apache下的RewriteRule
- <IfModule mod_rewrite.c>
- RewriteEngine On
- RewriteBase /
- RewriteRule ^post/([^/]+)\.html/trackback/?$ index.php?name=$1&tb=1 [L]
- RewriteRule ^post/([^/]+)\.html/feed/(feed|rdf|rss|rss2|atom)/?$ index.php?name=$1&feed=$2 [L]
- RewriteRule ^post/([^/]+)\.html/(feed|rdf|rss|rss2|atom)/?$ index.php?name=$1&feed=$2 [L]
- RewriteRule ^post/([^/]+)\.html/page/?([0-9]{1,})/?$ index.php?name=$1&paged=$2 [L]
- RewriteRule ^post/([^/]+)\.html/([0-9]+)/?$ index.php?name=$1&page=$2 [L]
- </IfModule>
如非注明则为本站原创文章,欢迎转载。转载请注明转载自:moon's blog
我的robots都是直接隐蔽/data/,也不知道有没有必要~~
正是需要的,谢谢博主分享。
页面下方的页面链接显示“http://www.m5050.com/freeziyuan/453-2.html”
但打开时显示http://www.m5050.com/freeziyuan/453.html/2
这是为什么啊? 😥
固定链接格式设置对吗?检查下后台固定链接的格式
我的也是 求解释
查看一下你后台固定链接格式设置的对吗?这个是要改的 😛
【状况同上】固定链接设置对了
""
""
"
po主,我按照上面的设置了,一步步设置,一步没差;
href链接显示正常,一点击(或者手动输入)就跳转了
http://127.0.0.1/html/2013/05/19/xxx-3.html
跳为:
http://127.0.0.1/html/2013/05/19/xxx.html/3
希望po主指教下 😥
"
2. 打开主题目录下的single.php文件,查找wp_link_pages并替换为my_wp_link_pages这步确定没有少吗,鼠标放到分页上看下链接对不对 😳
鼠标放在链接上显示的是对的,xxx-3.html格式,就是一点击就跳了,
诡异的是当我把后台的固定链接给为/p?=123的格式,虽然链接不显示静态格式,但是手动输入却能正常按照xxx-3.html的格式访问。
还真是诡异啊,你用的什么web服务器,apahce还nginx,你是不是配置了伪静态了
apahce,配置了伪静态,请问您的wordpress 什么版本?我的是最新版本 ❓
我apache和nginx都用过,都可以用啊,不用配置伪静态规则,我的.htaccess里也没什么
# BEGIN 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>
# END WordPress
用nginx时也就配置了
location /
{
if (!-e $request_filename)
{
rewrite (.*) /index.php last;
}
}
你好,如果是nginx的伪静态应该如何弄呢?
不用做设置就可以 😛
if (!-e $request_filename)
{
rewrite (.*) /index.php last;
}
我用的是lnmp上默认的,也不用修改吗?
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;
}
}
是的,不用修改就可以的
🙂 非常感谢
我也遇到这样的问题
http://www.geelg.com/creative/12328_3.html 点击之后就显示了下面的链入
http://www.geelg.com/creative/12328.html/3