【问题标题】:Trying to redirect all index.html on my wordpress site through my htaccess试图通过我的 htaccess 重定向我的 wordpress 网站上的所有 index.html
【发布时间】:2013-01-17 14:01:17
【问题描述】:

我正在尝试删除所有 index.html 文件和扩展名,就像我的 index.php 规则一样。 意思是,而不是

www.discretix/modules-hdcp/index.html

应该有

www.discretix/modules-hdcp/

它适用于index.php,但不适用于index.html。 我正在使用 wordpress,我的服务器是 apache。

这些是我的 htaccess 规则:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~discretix/
RewriteRule ^index\.php$ - [L]
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~discretix/index.php [L]
</IfModule>

【问题讨论】:

  • 您要进行实际的重定向吗? (服务器发送301 http状态码和新位置)

标签: html .htaccess rule


【解决方案1】:

以下规则将使用 301 重定向(永久移动)将用户从 index.html 或 index.php 重定向到文件夹(这将反映在客户端浏览器地址栏中),您可能希望将其更改为302重定向(原来是临时重定向,现在常用来指定重定向,原因不明)

RewriteBase /~discretix/
RewriteRule ^index\.(html|php)$ ./ [R=301,L]

【讨论】:

  • 谢谢。它适用于 index.php,但适用于 index.html - 它重定向到站点的根目录...
  • 谢谢!它似乎有效 - 我的缓存有问题,导致我无法看到您建议的解决方案!
猜你喜欢
  • 1970-01-01
  • 2011-07-17
  • 2016-07-04
  • 1970-01-01
  • 1970-01-01
  • 2017-07-17
  • 2018-08-19
  • 2017-06-26
  • 2015-10-22
相关资源
最近更新 更多