【问题标题】:Rewrite Rule how to make for folder重写规则如何为文件夹制作
【发布时间】:2020-01-05 07:36:03
【问题描述】:

我的 FTP 上有 2 个文件夹。

www/

www/test/

所以..

example.com

example.com/test

在文件夹中测试 是 htaccess 与

RewriteRule booking\.php booking.php 

但是当我点击链接时

<a href"/booking">Link</a>

将我重定向到 https://example.com/booking

但我需要重定向到 https://example.com/test/booking

你能帮帮我吗?

我知道如何用链接制作

<a href="/test/booking"> 

但我需要用 htaccess 来做这个。

【问题讨论】:

  • 你的重写规则不应该包含test吗?

标签: .htaccess mod-rewrite


【解决方案1】:

使用使用 ^$ 的重写规则,因为它代表根并将其重写到您的文件夹 /test ,如下所示:

使用这个方法:

重写引擎开启 重写规则 ^$ /test [L]

或者这个方法:

重写引擎开启 RewriteCond %{REQUEST_URI} !^/test 重写规则 ^(.*)$ /test/$1 [NC,L]

【讨论】:

    猜你喜欢
    • 2021-02-13
    • 1970-01-01
    • 2019-12-12
    • 2017-07-16
    • 2012-11-22
    • 2012-11-20
    • 1970-01-01
    • 1970-01-01
    • 2015-01-25
    相关资源
    最近更新 更多