【问题标题】:URL rewrite using htaccess from index.php to index.html使用 htaccess 从 index.php 重写 URL 到 index.html
【发布时间】:2013-04-04 22:17:00
【问题描述】:

我想重写网址

我使用 .htaccess 代码作为

RewriteEngine on
RewriteRule ^index.html$ index.php [L]

网址是http://www.example.com/dashboard/index.php

而我想将 url index.php 改写为 index.html

谁能给我改写的想法

【问题讨论】:

    标签: php mod-rewrite


    【解决方案1】:

    试试这个

    RewriteEngine on
    RewriteRule ^(.*)\.html$ $1.php [nc]
    

    【讨论】:

    • 不工作。我在 ubuntu 服务器上工作。我启用了 mod_rewrite。 mod_rewrite 启用有什么问题吗
    • 如果未启用,则无法正常工作。首先使用 php_info() 检查是否启用?
    【解决方案2】:

    取决于您的 .htaccess 文件在哪里。如果它在您的根文件夹中,那么您将拥有

     RewriteEngine on
     RewriteRule ^dashboard/index.html$ /dashboard/index.php [L]
    

    【讨论】:

      【解决方案3】:

      你可以使用 下面的代码

      RewriteEngine On
      RewriteRule ^(.*)\.html$ $1.php [L]
      

      如果您希望它作为重定向而不是仅仅重写来完成,请将 [L] 修改为 [L,R]

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-04-19
        • 1970-01-01
        • 2013-09-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多