【问题标题】:How to display post name right after domain through .htaccess如何通过.htaccess在域名之后显示帖子名称
【发布时间】:2018-12-29 06:03:38
【问题描述】:

我列出了帖子表单页面文章,目前看起来像这样: http://demo.web/articles/hello-world 我只想显示如下所示的网址:http://demo.web/hello-world 但问题是页面 articles 将使用 URL 中传递的 id 获取数据。 而且,我还在同一页面上列出了标题为其他帖子的其他文章。我已经在 http://demo.web/articles/hello-world 里面,如果我将鼠标悬停在同一页面的其他链接上,那么它会给出如下所示的 url: http://demo.web/articles/2/hello-world/articles/3/life-is-beautiful

我的意思是 URL 被附加到现有 URL 中。

最后,我希望我的网址看起来像这样:http://demo.web/hello-worldhttp://demo.web/life-is-beautiful

我的 .htaccess 文件有以下代码:

RewriteEngine On
RewriteRule ^([a-zA-Z]+)$ $1.php
RewriteRule ^articles/([0-9]+)/([a-z-]+) articles.php?id=$1&act=$2 

【问题讨论】:

    标签: .htaccess url url-rewriting


    【解决方案1】:

    就像您正在重写为相对路径。 尝试在 "articles.php?id=$1&act=$2" 前面添加 /

    【讨论】:

    猜你喜欢
    • 2015-01-10
    • 1970-01-01
    • 2021-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-07
    • 1970-01-01
    相关资源
    最近更新 更多