【问题标题】:Htaccess Redirect with Regular Expressions使用正则表达式进行 Htaccess 重定向
【发布时间】:2017-12-28 21:47:25
【问题描述】:

我有一个关于 htaccess 配置 win a PHP Project 的问题

我有这段代码可以使用重定向

DirectoryIndex src/client/index.php

Redirect /app/about http://localhost/app/?p=about
Redirect /app/contact http://localhost/app/?p=contact

在 src/client/index.php 中,我检查 GET[p] 以包含请求的页面。

它可以工作...但我不想每次添加新页面时都修改 htaccess 文件。

我想实现这样的东西,但它不起作用,我很确定我有语法错误

Redirect ^/app/(.*) http://localhost/app/?p=$1

感谢您的宝贵时间 :)

【问题讨论】:

    标签: apache .htaccess redirect mod-rewrite


    【解决方案1】:

    你只需要使用RedirectMatch:

    RedirectMatch ^/app/(.*) http://localhost/app/?p=$1
    

    【讨论】:

      猜你喜欢
      • 2019-08-20
      • 1970-01-01
      • 2013-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-21
      • 2014-12-05
      相关资源
      最近更新 更多