【问题标题】:Joomla without index.php (301 redirect)没有 index.php 的 Joomla(301 重定向)
【发布时间】:2012-12-18 10:35:34
【问题描述】:

我最近开始了 Joomla 的项目。我不得不从中删除 index.php (这是配置设置中的一些复选框)。我已经找到了怎么做。目前实际上所有的 URL 都是在没有 index.php 的情况下创建的。

但是,我可以直接输入网址http://mywebsite.com/index.php/article-name,而不是重写为http://mywebsite.com/article-name。 如果我有菜单,则 URL 正在正确创建(http://mywebsite.com/article-name - 所以没有 index.php)。

所以问题是: 如何为带有 index.php 的网站创建 htaccess 重定向到没有 index.php 的网站。

【问题讨论】:

    标签: .htaccess joomla


    【解决方案1】:

    由于您在内部将内容路由到 index.php,因此您必须匹配实际请求:

    RewriteCond %{THE_REQUEST} ^(GET|HEAD)\ /index\.php/[^\ ]+
    RewriteRule ^index\.php/(.*)$ /$1 [L,R=301]
    

    【讨论】:

      【解决方案2】:

      转到您的全局配置页面并进行以下更改:

      1. 打开 SEF(搜索引擎友好)URL 选项。
      2. 对 Apache mod_rewrite 说“是”
      3. 拒绝向 URL 添加后缀
      4. 向 Unicode 别名说不
      5. 拒绝在页面标题中包含网站名称。

      还将 htaccess.txt 更改为 .htaccess。现在在“重定向到这里”处添加新的重定向代码。

      代码

      #### 开始 - 301 重定向

      #

      RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\/([^/]+/)*(index|home).html?\HTTP/

      重写规则 ^(([^/]+/)*)(index|home).html?$ http://www.example.com/$1 [R=301,L]

      #

      RewriteCond %{THE_REQUEST} !^POST

      RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index.php\ HTTP/

      RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+>s)$

      重写规则 ^(([^/]+/)*)index.php$ http%2://www.example.com/$1 [R=301,L]

      #

      RewriteCond %{HTTP_HOST} !^(www.example.com)?$

      重写规则 (.*) http://www.example.com/$1 [R=301,L]

      #

      #### 结束 - 301 重定向

      注意:使用您的网站名称删除 www.example.com。

      【讨论】:

        猜你喜欢
        • 2013-11-01
        • 2017-03-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-02-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多