【问题标题】:Joomla 3.0 - redirect 301 remove index.php add .htmlJoomla 3.0 - 重定向 301 删除 index.php 添加 .html
【发布时间】:2013-11-01 22:36:17
【问题描述】:

我将旧的 joomla 网站迁移到了 Joomla 3.0。我将 URL 更改为 SEF 友好 URL,我需要将所有旧 URL (www.mysite.com/index.php/mypage) 重定向到新 URL (www.mysite.com/mypage.html) 我试图在我的 .htaccess 底部添加此代码,但它不起作用:

    RewriteEngine on
    RewriteRule ^/index.php/(.*)$ http://www.nextlog.it/$1 [R=301,L]
    RewriteRule ^/index.php/(.*)$ $1.html [R=301,L]

【问题讨论】:

  • “不起作用”无法清楚描述问题
  • “不起作用”我的意思是代码没有做任何事情。
  • @Olèp:你应该发布完整的DOCUMENT_ROOT/.htaccess

标签: .htaccess mod-rewrite redirect joomla


【解决方案1】:

您不需要第一条规则,如果这是在您的 htaccess 中,请删除正则表达式模式中的前导斜杠:

RewriteEngine on
RewriteRule ^index.php/(.+)$ /$1.html [R=301,L]

【讨论】:

  • @Olèp 如果代码没有做任何事情,请确保您已加载 mod_rewrite(在 httpd.conf 中),确保您的 htaccess 文件正在被读取(确保您至少有 AllowOverride FileInfoAllowOverride All)
  • 我确定 mod_rewrite 已加载并且 .htaccess 已被读取(我对代码进行了一些操作,它显示了一些错误)。
  • @Olèp Dunno 然后,因为默认 apache 测试安装中空白 htaccess 文件中的这些规则 does exactly what you asked
  • 那是joomla .htaccess相关的问题
  • @Olèp 它必须在您的 htaccess 文件中的任何其他规则之前
【解决方案2】:

我会使用内置的 com_redirect,它会进行永久重定向。随着时间的推移,搜索引擎将更新其索引以转到新页面,然后您可以删除重定向页面......但同时监控直接链接的来源。在更新直接链接之前,您需要保留这些内容。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-27
    • 2017-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多