【问题标题】:htaccess rewrite engine with gethtaccess 用 get 重写引擎
【发布时间】:2021-12-29 04:33:17
【问题描述】:

以下问题: 我的.htaccess 是这样的:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

RewriteRule "^user/([A-Z a-z 0-9_\-.]{1,})((/\w+)+|/?)$" "display_content/user/profile.php?name=$1"

在最后一条规则中,URL 从 /user/blabla 重定向到 /display_content/user/profile.php?name=blabla。但是现在我希望你输入/user/blabla/posts/ 你登陆例如/display_content/user/posts.php?name=blabla。有谁知道如何实现这一点?

已经谢谢了:)

哦,对不起,这是我关于堆栈溢出的第一个问题 :)

【问题讨论】:

    标签: php .htaccess webserver


    【解决方案1】:

    我不会尝试将其打包到第一个重写规则中,而是像这样创建第二个:

    RewriteRule "^user/([\w\-.]+)/posts/?$" "display_content/user/posts.php?name=$1"
    

    因此,我建议修改第一条规则;它似乎包含不必要的模式:RewriteRule "^user/([\w\-.]+)/?$" "display_content/user/profile.php?name=$1"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-08
      • 1970-01-01
      • 2015-07-21
      • 1970-01-01
      • 2014-02-15
      • 1970-01-01
      相关资源
      最近更新 更多