【发布时间】:2017-07-21 11:22:46
【问题描述】:
我目前在我的 Wordpress htaccess 文件中有这个:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html?$ / [NC,R,L]
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
#RedirectMatch 301 (.*)\.html$ $1/
我正在尝试将所有 .html 重定向到没有任何文件扩展名的 URL,即 www.example.com/about.html 到 www.example.com/about/。
代码在 /index.html 重定向到 / 时工作正常
上面的注释代码 (RedirectMatch 301 (.*)\.html$ $1/) 应该适用于将 .html 重定向到漂亮的 URL,但它也适用于 index.html,而不是将其重定向到 / 而是将其重定向到 /index
有没有办法让我压缩我的代码并做我想做的事?
【问题讨论】:
标签: wordpress .htaccess url permalinks