【问题标题】:Rewrite a URL to homepage将 URL 重写为主页
【发布时间】:2014-12-25 14:25:37
【问题描述】:

我要重写的 URL 是:http://domain.com/index.php?name=homehttp://domain.com/

我已经创建了 .htaccess 文件并将这段代码用于重写:

RewriteEngine On 
RewriteRule ^ index.php?name=home [L]

但它不起作用。我网站中的所有请求都将重定向到http://domain.com/。 帮我解决这个问题。谢谢你!

【问题讨论】:

    标签: .htaccess mod-rewrite url-rewriting


    【解决方案1】:

    您需要在您的正则表达式中添加“字符串结尾”匹配:

    RewriteEngine On 
    RewriteRule ^$ index.php?name=home [L]
    

    【讨论】:

      【解决方案2】:

      这通常是因为你的页面调用的结构,因为我不知道你的文件的来源以及你是如何通过 ftps 实现的,你需要组织你的页面,应该有一个名为 public 的文件夹,这个文件夹通常包含你的该 .htaccess 中的公共页面以及您的脚本文件。

      【讨论】:

        猜你喜欢
        • 2014-12-17
        • 1970-01-01
        • 2012-01-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多