【问题标题】:htaccess redirect requests to index.php with former paths as query stringhtaccess 将请求重定向到 index.php,以前的路径作为查询字符串
【发布时间】:2020-02-13 17:05:50
【问题描述】:

我正在尝试使用 htaccess 文件将所有请求(css、js 和图像除外)重定向(而不是重写)到我的 index.php 文件,并将以前的路径作为查询字符串传递。

example.de/path/test -> example.de?path1=path&path2=test

我已经在这里寻找了一些答案,但是他们都使用了重写

感谢您的帮助

【问题讨论】:

    标签: php .htaccess redirect


    【解决方案1】:

    看看这是否有帮助:

    原网址:

    http://www.example.com/index.php?id=100

    所需的目标网址:

    http://www.example.com/100/

    .htaccess 语法:

    RewriteEngine On
    RewriteRule ^([^/d]+)/?$ index.php?id=$1 [QSA]
    

    您可以在这里进一步探索:

    https://gist.github.com/ScottPhillips/1721489

    【讨论】:

      猜你喜欢
      • 2013-03-24
      • 2018-12-02
      • 2012-10-11
      • 2021-12-10
      • 1970-01-01
      • 2016-11-30
      • 2015-01-08
      • 1970-01-01
      • 2015-04-10
      相关资源
      最近更新 更多