小编Jer*_*emy的帖子

如何使用htaccess重定向html扩展?

目前,这两个链接都显示相同的页面:

http://www.example.com/podcast/episode.html
http://www.example.com/podcast/episode

我想要做的是将所有html类型链接重定向到非HTML链接.

我知道这对htaccess来说可能看起来很简单,但它对我不起作用.

到目前为止,这是我的htaccess代码:

    RewriteEngine On
    RewriteBase /

    #removing trailing slash

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ $1 [R=301,L]

    #non www to www

    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

    #shtml

    AddType text/html .html
    AddHandler server-parsed .html

    #html

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^\.]+)$ $1.html [NC,L]

    #index redirect

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/ 
    RewriteRule ^index\.html$ http://example.com/ [R=301,L]
Run Code Online (Sandbox Code Playgroud)

html .htaccess file-extension

6
推荐指数
1
解决办法
9599
查看次数

WordPress——如何使随机帖子出现在主页上?

有没有办法让每次有人刷新我的自托管 WordPress 博客的主页时都会显示不同的帖子?

目前我将主页设置为仅显示 1 篇文章,但这只是最新的一篇。我希望每次有人访问我的网站时都会有所不同,从所有帖子的存档中随机提取帖子。

这是我正在使用的主题中当前循环的样子:

<?php
}

// Load main loop
if ( have_posts() ) {

// Start of the Loop
while ( have_posts() ) {
the_post();
?>
Run Code Online (Sandbox Code Playgroud)

有什么办法可以实现这一点吗?

我也不想保留“博客页面最多显示 1 个帖子”设置,因为这会弄乱我的搜索结果(每个结果都在单独的页面上),但我只想在主页循环上显示 1 个帖子。

php wordpress themes loops

1
推荐指数
1
解决办法
2356
查看次数

标签 统计

.htaccess ×1

file-extension ×1

html ×1

loops ×1

php ×1

themes ×1

wordpress ×1