【问题标题】:Rewrite using .htaccess file使用 .htaccess 文件重写
【发布时间】:2023-03-18 17:00:01
【问题描述】:

我想重写一个网址

http://www.example.com/folder1/index.php/commonfuntion/about”到“http://www.example.com/about.html”。

我在文件夹 1 中的 htaccess 文件中尝试了以下代码:-

RewriteEngine On

RewriteRule about.html$  /folder1/index.php/commonfuntion/about [L] 

但是我没有得到想要的结果。如何完成任务?

【问题讨论】:

    标签: .htaccess


    【解决方案1】:

    以下代码可能会解决您的问题

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www.example.com/folder1/index.php/commonfuntion/about$ [OR]
    RewriteRule (.*)$ http://www.example.com/about.html$1 [R=301,L]
    

    【讨论】:

      【解决方案2】:

      您需要将您的规则放在文档根目录,folder1 的父文件夹中。因为您尝试访问的 URL,http://www.example.com/about.html 不在文件夹 1 中。

      另外,别忘了打开重写引擎:

      RewriteEngine On
      RewriteRule about.html$ /folder1/index.php/commonfuntion/about [L] 
      

      【讨论】:

        猜你喜欢
        • 2023-03-03
        • 2013-04-22
        • 2017-04-08
        • 2021-12-20
        • 1970-01-01
        • 1970-01-01
        • 2014-03-24
        • 2020-07-14
        • 2010-11-18
        相关资源
        最近更新 更多